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
Community Moderator Alumni are previous members of the Moderation Team, which ensures conversations are friendly, factual, and on-topic. Moderators are here to answer questions, escalate bugs, and make sure your voice is heard by the larger Fitbit team. Learn more
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?
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
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
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
Would you please provide me the endpoint you're executing where you do not see isMainSleep returned?
Thanks!
Gordon
Best AnswerHi 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.
As stated in the original question from 2+ years ago:
"When requesting logs for a single date, the field is present."
Best AnswerisMainSleep 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
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
@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
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
@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