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

Calories and steps endpoints returning no data

I'm using the endpoint API to retrieve my Fitbit data. All seems okay except that, since yesterday (possibly earlier than that, as I have been on holiday), using the endpoints for retrieving calories and steps returns no data.

For example:

https://api.fitbit.com/1/user/-/activities/calories/date/YYYY-MM-DD/1d.json 

returns no data.

Yesterday, this worked about 10% of the time, but returned no data the other 90% of the time. Today, this returns no data all the time.

This issue also arises when trying to retrieve data (steps, calories, heart rate) from individual exercise activities.

Why is this happening??

Best Answer
0 Votes
5 REPLIES 5

Hi @mrchurch - is your watch properly syncing?

Author | ch, passion for improvement.

Best Answer
0 Votes

Hi @mrchurch 

I tested the endpoint using the Web API Explorer tool and I was able to get data back.   What are the dates that you're querying, and are you sure the data exists?   Are you getting an error or just an empty response?   

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes
My application told me it had received no data from the endpoint. Further
investigation showed that the endpoint WAS receiving data, but that the
data contained only the calorie count total for the day. It no longer
includes the minute-by-minute calorie count... and that is what my
application is complaining about.

The same is true for the steps data. I get the daily total, but not the
minute-by-minute data.
Best Answer
0 Votes

So I've investigated further, and the problem lies in the fact that the JSON returned by the calories and steps endpoints is now "prettified" (i.e. it has been formatted using newlines and spaces to be human-readable). Before now, the JSON returned contained no formatting white space.

It would appear that the JSON library I am using cannot cope with such formatting whitespace.

It also didn't help that those two endpoints also used to return the intraday data when requesting a single day's data - but now doesn't. That was an easy fix, I now use the endpoint as follows:

https://api.fitbit.com/1/user/-/activities/calories/date/YYYY-MM-DD/1d/1min.json 

However, that still returns JSON containing formatting whitespace.

Thanks for your help...

Best Answer
0 Votes

I'm pretty sure that the various endpoints are contracted to return the JSON data as a "single line of JSON" (i.e. with no formatting whitespace) in order to minimise the size of the data packet being returned.

It turns out that my application has been written on the understanding that this is the case. Indeed, every other endpoint honours this contract ... so why are these different? Is it a bug?

I mean, I could change my app so that it removes the formatting whitespace before handing the JSON over to the back-end processing unit, but that seems like ME having to counter an API bug...

---

My application has been written to consider the returned data to be valid if and only if it is a single non-empty line of text. If it is zero lines or two or more lines, it is thus considered invalid data.

Sure, this is an over-robust requirement (in theory), but it has never failed me before now. And, as indicated in my first post, two days ago, the endpoints were honouring the "single-line JSON" contract on about 10% of all requests. So, this looks like a deliberate change being made by the Fitbit developers to no longer deliver unformatted JSON...

Best Answer
0 Votes