Google Fit REST 心率查询要使用什么数据源 ID?
What data source ID to use for Google Fit REST heart rate query?
我正在尝试使用 Google Fit REST API, but I'm struggling because either I'm missing something or the documentation seems to be very incomplete. I've successfully managed to retrieve aggregate daily step count by following one of the few available examples:
检索汇总的每日心率摘要数据
请求URL
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
请求正文
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 },
"startTimeMillis": 1438705622000,
"endTimeMillis": 1439310422000
}
我找不到任何读取心率的示例,因此我正在尝试针对心率修改此示例。我发现 this list of data types 的数据类型为:com.google.heart_rate.summary
但没有任何关于 dataSourceId
应该是什么的信息。我试着忽略它,但我收到这个错误:
no default datasource found for: com.google.heart_rate.summary
有人知道我需要为 dataSourceId 使用什么,或者有 link 任何关于数据源的体面文档吗?
对于给定的数据类型,您可以list the data sources available,例如:
方法
GET
请求URL
https://www.googleapis.com/fitness/v1/users/me/dataSources?dataTypeName=com.google.heart_rate.summary
根据您想要实现的目标,您可能会找到 com.google.heart_rate.summary
或 com.google.heart_rate.bpm
的来源来满足您的需求,包括合并的来源。
对于静息心率,我使用这个:
"derived:com.google.heart_rate.bpm:com.google.android.gms:resting_heart_rate<-merge_heart_rate_bpm"
对于心率或 BPM,我使用这个:
"derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm"
为了完整起见,我在下面包含了我用于各种阅读的数据源:
DATA_SOURCE = {
"steps": "derived:com.google.step_count.delta:com.google.android.gms:merge_step_deltas",
"dist": "derived:com.google.distance.delta:com.google.android.gms:from_steps<-merge_step_deltas",
"bpm": "derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm",
"rhr": "derived:com.google.heart_rate.bpm:com.google.android.gms:resting_heart_rate<-merge_heart_rate_bpm",
"sleep" : "derived:com.google.sleep.segment:com.google.android.gms:sleep_from_activity<-raw:com.google.activity.segment:com.heytap.wearable.health:stream_sleep",
"cal" : "derived:com.google.calories.expended:com.google.android.gms:from_activities",
"move": "derived:com.google.active_minutes:com.google.android.gms:from_steps<-estimated_steps",
"points" : "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes",
"weight" : "derived:com.google.weight:com.google.android.gms:merge_weight"
}
根据数据源的不同,有时它会提供一个点数组。然后,您可以选择相应地对数组中的所有点求和、均值、中值等。
我正在尝试使用 Google Fit REST API, but I'm struggling because either I'm missing something or the documentation seems to be very incomplete. I've successfully managed to retrieve aggregate daily step count by following one of the few available examples:
检索汇总的每日心率摘要数据请求URL
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
请求正文
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 },
"startTimeMillis": 1438705622000,
"endTimeMillis": 1439310422000
}
我找不到任何读取心率的示例,因此我正在尝试针对心率修改此示例。我发现 this list of data types 的数据类型为:com.google.heart_rate.summary
但没有任何关于 dataSourceId
应该是什么的信息。我试着忽略它,但我收到这个错误:
no default datasource found for: com.google.heart_rate.summary
有人知道我需要为 dataSourceId 使用什么,或者有 link 任何关于数据源的体面文档吗?
对于给定的数据类型,您可以list the data sources available,例如:
方法
GET
请求URL
https://www.googleapis.com/fitness/v1/users/me/dataSources?dataTypeName=com.google.heart_rate.summary
根据您想要实现的目标,您可能会找到 com.google.heart_rate.summary
或 com.google.heart_rate.bpm
的来源来满足您的需求,包括合并的来源。
对于静息心率,我使用这个:
"derived:com.google.heart_rate.bpm:com.google.android.gms:resting_heart_rate<-merge_heart_rate_bpm"
对于心率或 BPM,我使用这个:
"derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm"
为了完整起见,我在下面包含了我用于各种阅读的数据源:
DATA_SOURCE = {
"steps": "derived:com.google.step_count.delta:com.google.android.gms:merge_step_deltas",
"dist": "derived:com.google.distance.delta:com.google.android.gms:from_steps<-merge_step_deltas",
"bpm": "derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm",
"rhr": "derived:com.google.heart_rate.bpm:com.google.android.gms:resting_heart_rate<-merge_heart_rate_bpm",
"sleep" : "derived:com.google.sleep.segment:com.google.android.gms:sleep_from_activity<-raw:com.google.activity.segment:com.heytap.wearable.health:stream_sleep",
"cal" : "derived:com.google.calories.expended:com.google.android.gms:from_activities",
"move": "derived:com.google.active_minutes:com.google.android.gms:from_steps<-estimated_steps",
"points" : "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes",
"weight" : "derived:com.google.weight:com.google.android.gms:merge_weight"
}
根据数据源的不同,有时它会提供一个点数组。然后,您可以选择相应地对数组中的所有点求和、均值、中值等。