訓練 - JSON 匯出格式

JSON 匯出中訓練結構的文件

Last updated: February 6, 2026

On this page

訓練

訓練資料包括您在 Apple Health 中記錄的所有運動會話,如跑步、騎行、游泳、力量訓練等。在 JSON 匯出中,訓練儲存在 workouts 陣列中。

匯出版本

Health Auto Export 支援兩種訓練匯出版本:

  • 版本 2(推薦):增強格式,包含更詳細的元資料和結構化資料
  • 版本 1(舊版):為與現有工作流程相容而保留的舊格式

訓練版本 2

版本 2 提供了包含選用欄位的全面結構,這些欄位僅在資料可用時包含。

基本結構

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Running",
  "start": "2024-02-06 07:00:00 -0800",
  "end": "2024-02-06 07:30:00 -0800",
  "duration": 1800
}

必要欄位

  • id (String): 訓練的唯一識別碼
  • name (String): 訓練類型名稱(例如:「Running」、「Cycling」、「Swimming」)
  • start (Date): 訓練開始時間,格式為 yyyy-MM-dd HH:mm:ss Z
  • end (Date): 訓練結束時間,格式為 yyyy-MM-dd HH:mm:ss Z
  • duration (Number): 訓練持續時間(秒)

選用欄位

以下欄位僅在資料可用時包含:

位置資訊

{
  "location": "Outdoor",
  "isIndoor": false
}
  • location (String): "Indoor""Outdoor""Pool""Open Water" 之一
  • isIndoor (Boolean): 訓練是否在室內進行

能量和強度

{
  "activeEnergyBurned": {
    "qty": 350,
    "units": "kcal"
  },
  "totalEnergy": {
    "qty": 450,
    "units": "kcal"
  },
  "intensity": {
    "qty": 8.5,
    "units": "MET"
  }
}
  • activeEnergyBurned (Object): 訓練期間消耗的活躍卡路里
  • totalEnergy (Object): 消耗的總卡路里(活躍 + 靜息)
  • intensity (Object): 任務代謝當量 (MET) 值

距離和速度

{
  "distance": {
    "qty": 3.5,
    "units": "mi"
  },
  "speed": {
    "qty": 7.0,
    "units": "mph"
  },
  "avgSpeed": {
    "qty": 7.0,
    "units": "mph"
  },
  "maxSpeed": {
    "qty": 8.5,
    "units": "mph"
  }
}
  • distance (Object): 總行駛距離
  • speed (Object): 目前或平均速度
  • avgSpeed (Object): 整個訓練的平均速度
  • maxSpeed (Object): 達到的最大速度

單位:

  • 距離:"mi"(英里)或 "km"(公里)
  • 速度:"mph"(英里/小時)或 "kmph"(公里/小時)

海拔

{
  "elevationUp": {
    "qty": 500,
    "units": "ft"
  },
  "elevationDown": {
    "qty": 450,
    "units": "ft"
  }
}
  • elevationUp (Object): 總海拔增益
  • elevationDown (Object): 總海拔損失

單位: "ft"(英尺)或 "m"(米)

環境資料

{
  "temperature": {
    "qty": 72,
    "units": "degF"
  },
  "humidity": {
    "qty": 65,
    "units": "%"
  }
}
  • temperature (Object): 訓練期間的環境溫度
  • humidity (Object): 相對濕度百分比

溫度單位: "degF"(華氏度)或 "degC"(攝氏度)

游泳專用欄位

{
  "lapLength": {
    "qty": 0.025,
    "units": "mi"
  },
  "strokeStyle": "Freestyle",
  "swolfScore": 45,
  "salinity": "Fresh Water",
  "totalSwimmingStrokeCount": {
    "qty": 1200,
    "units": "count"
  },
  "swimCadence": {
    "qty": 30,
    "units": "spm"
  }
}
  • lapLength (Object): 每圈的長度
  • strokeStyle (String): 以下之一:
    • "Backstroke"
    • "Breaststroke"
    • "Butterfly"
    • "Freestyle"
    • "Mixed"
    • "Kickboard"
    • "Unknown"
  • swolfScore (Number): 游泳效率分數
  • salinity (String): "Fresh Water""Salt Water"
  • totalSwimmingStrokeCount (Object): 總划水次數
  • swimCadence (Object): 每分鐘划水次數

步數和步頻資料

{
  "stepCount": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 5000,
      "units": "count",
      "source": "Apple Watch"
    }
  ],
  "stepCadence": {
    "qty": 180,
    "units": "spm"
  },
  "flightsClimbed": {
    "qty": 10,
    "units": "count"
  }
}
  • stepCount (Array): 隨時間變化的步數測量陣列
  • stepCadence (Object): 每分鐘步數
  • flightsClimbed (Object): 爬樓梯的層數

心率資料

{
  "heartRate": {
    "min": {
      "qty": 120,
      "units": "bpm"
    },
    "avg": {
      "qty": 150,
      "units": "bpm"
    },
    "max": {
      "qty": 175,
      "units": "bpm"
    }
  },
  "maxHeartRate": {
    "qty": 175,
    "units": "bpm"
  },
  "avgHeartRate": {
    "qty": 150,
    "units": "bpm"
  },
  "heartRateData": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "Min": 120,
      "Avg": 150,
      "Max": 175,
      "units": "bpm",
      "source": "Apple Watch"
    }
  ],
  "heartRateRecovery": [
    {
      "date": "2024-02-06 07:30:00 -0800",
      "Min": 140,
      "Avg": 145,
      "Max": 150,
      "units": "bpm",
      "source": "Apple Watch"
    }
  ]
}
  • heartRate (Object): 包含最小、平均和最大心率的摘要
  • maxHeartRate (Object): 訓練期間的最大心率
  • avgHeartRate (Object): 訓練期間的平均心率
  • heartRateData (Array): 整個訓練的詳細心率測量
  • heartRateRecovery (Array): 恢復期間的心率測量

時間序列資料陣列

啟用「包含訓練指標」時,許多指標可以作為時間序列陣列包含:

{
  "activeEnergy": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 50,
      "units": "kcal",
      "source": "Apple Watch"
    }
  ],
  "basalEnergy": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 20,
      "units": "kcal",
      "source": "Apple Watch"
    }
  ],
  "cyclingCadence": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 90,
      "units": "rpm",
      "source": "Apple Watch"
    }
  ],
  "cyclingDistance": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 0.5,
      "units": "mi",
      "source": "Apple Watch"
    }
  ],
  "cyclingPower": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 200,
      "units": "W",
      "source": "Power Meter"
    }
  ],
  "cyclingSpeed": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 18,
      "units": "mph",
      "source": "Apple Watch"
    }
  ],
  "swimDistance": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 25,
      "units": "yd",
      "source": "Apple Watch"
    }
  ],
  "swimStroke": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 20,
      "units": "count",
      "source": "Apple Watch"
    }
  ],
  "walkingAndRunningDistance": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 0.25,
      "units": "mi",
      "source": "Apple Watch"
    }
  ]
}

QuantityData 結構:

  • date (Date): 測量的時間戳記
  • qty (Number): 數量值
  • units (String): 測量單位
  • source (String, 選用): 資料來源裝置或應用程式

HeartRateData 結構:

  • date (Date): 測量的時間戳記
  • Min (Number): 最小心率
  • Avg (Number): 平均心率
  • Max (Number): 最大心率
  • units (String): 單位(通常為 "bpm")
  • source (String, 選用): 資料來源裝置或應用程式

路線資料

啟用「包含路線資料」且訓練有 GPS 資料時:

{
  "route": [
    {
      "latitude": 37.7749,
      "longitude": -122.4194,
      "altitude": 50.5,
      "course": 45.0,
      "courseAccuracy": 5.0,
      "horizontalAccuracy": 10.0,
      "verticalAccuracy": 15.0,
      "timestamp": "2024-02-06 07:00:00 -0800",
      "speed": 7.0,
      "speedAccuracy": 0.5
    }
  ]
}

位置欄位:

  • latitude (Number): GPS 緯度座標
  • longitude (Number): GPS 經度座標
  • altitude (Number): 海拔(米)
  • course (Number): 行駛方向(度,0-360)
  • courseAccuracy (Number): 航向測量精度(度)
  • horizontalAccuracy (Number): 水平位置精度(米)
  • verticalAccuracy (Number): 垂直位置精度(米)
  • timestamp (Date): 記錄位置的時間
  • speed (Number): 速度(米/秒)
  • speedAccuracy (Number): 速度測量精度(米/秒)

元資料

{
  "metadata": {
    "customField": "value",
    "anotherField": 123
  }
}
  • metadata (Object): 與訓練關聯的額外自訂元資料

訓練版本 1(舊版)

版本 1 使用更簡單的結構。對於新匯出,建議使用版本 2。

版本 1 結構

{
  "name": "Running",
  "start": "2024-02-06 07:00:00 -0800",
  "end": "2024-02-06 07:30:00 -0800",
  "totalEnergy": {
    "qty": 450,
    "units": "kcal"
  },
  "activeEnergy": {
    "qty": 350,
    "units": "kcal"
  },
  "distance": {
    "qty": 3.5,
    "units": "mi"
  },
  "heartRateData": [
    {
      "date": "2024-02-06 07:00:00 -0800",
      "qty": 150,
      "units": "count"
    }
  ],
  "route": [
    {
      "lat": 37.7749,
      "lon": -122.4194,
      "altitude": 50.5,
      "timestamp": "2024-02-06 07:00:00 -0800"
    }
  ]
}

訓練指標時間分組

使用匯出版本 2 且啟用「包含訓練指標」時,您可以控制時間序列資料的粒度:

  • 分鐘:按分鐘間隔對訓練指標進行分組
  • :按秒間隔對訓練指標進行分組(更詳細,檔案更大)

提示

  • 包含路線資料:啟用此選項以取得戶外訓練的 GPS 路線資訊
  • 包含訓練指標:啟用此選項以取得心率、功率和步頻等指標的詳細時間序列資料
  • 匯出版本:使用版本 2 以獲得最全面的資料結構
  • GPX 匯出:路線資料也可以匯出為獨立的 GPX 檔案,用於地圖應用程式

相關文件