Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read user's Google Fit activities through REST calls

I have seen that a Fitness History API already exists for android but i can't find anything similar for REST services. All i want to do is get the fitness activities of an authorized user's account. For example, i would like to get all the "walking" activities that he did in a specific day or period. Is there a simple way of doing this from a web app, since the documentation can be confusing?

like image 262
Envy Avatar asked Oct 19 '22 07:10

Envy


1 Answers

Fit has a full REST API available. To get activities (called sessions in the API) you'll want to use the Users.sessions.list method. It supports startTime and endTime parameters to timebox results and once you have the results you can filter them based on activityType. In this case activityType for walking is 7 but also potentially 93, 94, and 95 for more specific types of walking.

If you get an access_token authorized with the scope of 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
like image 70
abraham Avatar answered Oct 21 '22 23:10

abraham