Read user Google Fit activity via REST calls

I've seen that a health history API already exists for Android, but I can't seem to find anything similar for REST services. All I want to do is get the fitness activity of an authorized user account. For example, I would like to receive all the "walking" actions that he performed on a certain day or period. Is there an easy way to do this from within a web app as the documentation can get confusing?

+3


source to share


1 answer


Fit has a full REST API available . To get actions (called sessions in the API), you'll want to use the Users.sessions.list method . It supports parameters startTime

and endTime

to produce results in time, and as soon as you get the results, you can filter them based on ActivityType . In this case, activityType

for a walk - 7

but it is also possible 93

, 94

and 95

for more specific types of walking.

If you've gotten access_token

resolved using scope https://www.googleapis.com/auth/fitness.activity.read

, you can get a list of sessions for the current user as simple as:



https://www.googleapis.com/fitness/v1/users/me/sessions?access_token=xyz123

      

+1


source







All Articles