Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Swim data in Web API

ANSWERED

Hello.

I'm trying to get the distance swam data for my android/ios app.

I would like to use this endpoint

GET /1/user/[user-id]/[resource-path]/date/[base-date]/[end-date].json

But this only gives "distance" which seems to be walking/running data. So i tried using this one which gives a lot more detail:

GET https://api.fitbit.com/1/user/[user-id]/activities/date/[date].json

 

This one gave me this activity data in response for the day I took a swim:

 

 

 "activities": [
        {
            "activityId": 90024,
            "activityParentId": 90024,
            "activityParentName": "Swim",
            "calories": 314,
            "description": "less than 25 yards/min",
            "distance": 0,
            "duration": 2355000,
            "hasActiveZoneMinutes": false,
            "hasStartTime": true,
            "isFavorite": false,
            "lastModified": "2020-09-06T12:24:34.000Z",
            "logId": 34073552772,
            "name": "Swim",
            "startDate": "2020-09-06",
            "startTime": "13:40",
            "steps": 0
        }
    ],

 

As you can see under "name" it is indeed a Swim, but the distance says 0, even though you can see the duration was quite long.

If i look inside the fitbit app, there is no "distance kilometers" data but a "lengths" data:

 

https://imgur.com/KjWeYpI

 

It is in Swedish (sorry), but you can see it displays a length property instead of kilometers, is there anyway to retrieve this length property instead of distance (which gives me 0) in the web API?

Thanks

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

For your use case, the Get Activity Log List endpoint will not provide distance, but it will provide you with the number of "swimLengths".   

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
5 REPLIES 5

Hi @calleman123 

 

The best endpoints to get exercise stats are either the Get Daily Activity Summary or the Get Activity Log List endpoints.   Any of the data you see in the mobile application will come through in the API.  It sounds like the device didn't record distance.  You might need to set the default lap length first.   Here's an article that describes everything about the swim exercise and getting it enabled on your device, https://help.fitbit.com/articles/en_US/Help_article/2087.htm#How.

 

It could also be related to the device that you're using.  Which device are you using while swimming?

 

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

@GordonFitbitThanks so much for taking your time to help.

 

I'm using a FitBit Inspire (not the HR). This one cannot set the lap length, it should be automatically tracked:

https://community.fitbit.com/t5/Inspire-Inspire-HR/How-do-I-set-the-pool-length-in-the-Inspire/td-p/...

 

Indeed it didn't track my distance, but it tracked the laps as you can see in the imgur link. So i'm still not sure what might be going on...

Best Answer
0 Votes

Hi @calleman123, would you please private message me your Fitbit User ID?   Let me see if I can determine where the lap data might be available.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

@GordonFitbitYes thank you. Doing it now.

Best Answer
0 Votes

For your use case, the Get Activity Log List endpoint will not provide distance, but it will provide you with the number of "swimLengths".   

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer