训练 - JSON 导出格式
JSON 导出中训练结构的文档
Last updated: February 6, 2026
训练
训练数据包括您在 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 Zend(Date): 训练结束时间,格式为yyyy-MM-dd HH:mm:ss Zduration(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 文件,用于地图应用