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

Sleep API get by date range missing isMainSleep

Hi,

 

I am using the new v1.2 sleep API, and have noticed that when requesting sleep logs by date range, the isMainSleep attribute is missing from the returned sleep logs. The API reference - https://dev.fitbit.com/docs/sleep/#get-sleep-logs-by-date-range shows that the field should be there, and states that the endpoint "returns a list of a user's sleep log entries (including naps)", so it is not clear which entries are naps. When requesting logs for a single date, the field is present.

 

Could you please explain the discrepancy between the reference and the data returned, and how we should differentiate between naps and main sleep when retrieving data over a range?

 

Thanks

Best Answer
12 REPLIES 12

@sleepster Thanks for pointing this out. I'll pass it along to get it clarified.

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer

Hey @AndrewFitbit,

 

I can see that this has been reported quite a long time ago. Unfortunately, as of today this still seems to be the case. Could you please provide an update about the state of this issue?

Best Answer

Just to add more information -- this field is missing for all date range results.  I initially thought it was only missing for days with only one sleep (i.e., days where it's obvious what the main sleep is), but it's also missing for days with multiple sleep intervals.  This is clearly a bug, not a feature.  Please fix. It's amazing that this was flagged up 6 months ago and still has not been addressed.   And not the good kind of amazing 😉 

Best Answer
0 Votes
I totally agree. For now as a workaround, we've decided to select the sleep with the max durationOfSleep value for each days out of the response for a date range. But obviously this is not the preferable solution, but only a workaround.
Best Answer
0 Votes

@AndrewFitbit any updates on this?

Best Answer

Same situation after more than 2 years.

Best Answer
0 Votes

Hi @salvadormoreno 

 

I'm not sure when it was added, but I see isMainSleep is returned by the sleep API.  When I execute

 

https://api.fitbit.com/1.2/user/-/sleep/date/2019-09-09.json

 

I get the following output

 

Screen Shot 2019-09-09 at 11.19.43 AM.png

 

Would you please provide me the endpoint you're executing where you do not see isMainSleep returned?

 

Thanks!

Gordon

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

Hi Gordon,

 

The issue is only present when you request the sleep logs by date range. When requesting logs for a single date, the field is present.

 

 

Best Answer

As stated in the original question from 2+ years ago: 

"When requesting logs for a single date, the field is present."

Best Answer
0 Votes

isMainSleep dissapears from the output when a daterange is requested (for example, https://api.fitbit.com/1.2/user/-/sleep/date/2019-09-09/2019-09-11.json) instead of a single day, as you posted.

Best Answer
0 Votes

@salvadormoreno Thanks for following up on this topic. Our team is looking into it as we speak and I'll provide you with an update once I have it.

 

I appreciate your patience so far, please let me know if you have any additional questions in the meantime.

Best Answer
0 Votes

@sleepster @salvadormoreno Thank you for all your patience. Our team has confirmed that the isMainSleep attribute was re-added to the Get Sleep by date range endpoint. Please go ahead and query the endpoint and let me know if you are still not seeing it.

Best Answer
0 Votes