5

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?

Envy
  • 51
  • 3

1 Answers1

3

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
abraham
  • 46,583
  • 10
  • 100
  • 152
  • 4
    Hello, First of all thanks for your time and sorry for that late answer. The method you described seems fine for activities entered manually through the web browser but i cannot fetch the activities monitored by the device. If you have google-fit on your smartphone it will constantly monitor your walking, but this data isn't available through sessions. Is there anything i'm missing? P.S. i have tried to go through dataSources to get some info but i found it extremely confusing – Envy Jul 23 '15 at 14:53
  • @abraham. We can get all activity list here. Where we can find steps count for that activity. I mean individual? – Bhavin Chauhan Sep 25 '15 at 07:11
  • 1
    @Envy Same experience here. Were you ever able to figure out how to get the activities automatically entered via smart devices? – theblang Mar 03 '17 at 03:30
  • @theblang Facing the same issue right now. Manually entered activities show up in sessions.list results but automatically tracked ones do not. – felschr May 14 '19 at 15:56