本文介绍了如何从 Google Fitness REST api 检索步数数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

自从我在 Nexus 5 上安装 Google Fit 应用程序以来,它一直在跟踪我的步数和步行时间.我想通过 Google Fitness REST api(docs)检索此信息,但我可以不知道如何从 REST api 中获取任何这些数据.

Since I installed the Google Fit app on my Nexus 5 it has been tracking my step count and time spent walking. I'd like to retrieve this info via the Google Fitness REST api (docs) but I can't work out how to get any of that data from the REST api.

我已经使用 OAuth 2.0 playground 成功列出了数据源,但我尝试过的示例都没有返回任何健身数据.我觉得我需要使用类似于 (Android SDK) 但我不是在构建 Android 应用程序——我只想访问 Google Fit 应用程序已经存储的健身数据.

I've used the OAuth 2.0 playground to successfully list dataSources but none of the examples I have tried have returned any fitness data whatsoever. I feel like I need to use something similar to a DataReadRequest from the (Android SDK) but I'm not building an Android app -- I just want to access fitness data already stored by the Google Fit app.

甚至可以获取 Google Fit 应用程序收集的数据吗?如果是这样,我如何使用 REST api 读取和聚合步数数据?

Is it even possible to get the data gathered by the Google Fit app? If so, how can I read and aggregate step count data using the REST api?

推荐答案

原来答案在docs.这是请求的格式.

It turns out that the answer is in the docs after all. Here is the format of the request.

GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}

唯一支持的 {userId} 值为 me(带身份验证).

The only supported {userId} value is me (with authentication).

{dataSourceId} 的可能值可通过运行 不同的请求.

Possible values for {dataSourceId} are avaiable by running a different request.

我错过的一点是 {datasetId} 并不是真正的 ID,而是您定义感兴趣的时间跨度的位置.该变量的格式为 {startTime}-{endTime},其中时间以自纪元以​​来的纳秒为单位.

The bit I missed was that {datasetId} is not really an ID, but actually where you define the timespan in which you are interested. The format for that variable is {startTime}-{endTime} where the times are in nanoseconds since the epoch.

这篇关于如何从 Google Fitness REST api 检索步数数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:10