08-01-2016 12:37
08-01-2016 12:37
Below is an example of some output from the Sleep startTime time series. The dateTime value is always off by one day for this user. What am I not seeing? How can I figure out the correct starting day (the time is correct).
Thanks!
( { dateTime = "2016-07-24"; value = 441; }, { dateTime = "2016-07-25"; value = 452; }, { dateTime = "2016-07-26"; value = 461; }, { dateTime = "2016-07-27"; value = 439; }, { dateTime = "2016-07-28"; value = 483; }, { dateTime = "2016-07-29"; value = 451; }, { dateTime = "2016-07-30"; value = 435; }, { dateTime = "2016-07-31"; value = 312; }, { dateTime = "2016-08-01"; value = 486; } )
Answered! Go to the Best Answer.
08-02-2016 08:38
08-02-2016 08:38
@ThatOneCat Are you expecting to see the date of the night they went to sleep? Because sleep is logged on the date the user woke up, not the night they went to sleep.
08-02-2016 08:38
08-02-2016 08:38
@ThatOneCat Are you expecting to see the date of the night they went to sleep? Because sleep is logged on the date the user woke up, not the night they went to sleep.
08-02-2016 17:31
08-02-2016 17:31
08-03-2016 16:43
08-03-2016 16:43
@ThatOneCat If it's after midnight (and assuming they don't sleep until 12am the next day ) then it will still be logged on that day.
Here's what it looks like using my account and this endpoint:
https://api.fitbit.com/1/user/-/sleep/startTime/date/today/2016-05-11.json
I have sleep logged on May 11th, but went to sleep 11:34pm May 10th
"dateTime": "2016-05-11",
"value": "23:34"
"value" shows that I went to sleep at 23:34 (11:34pm) but the sleep is still logged on the 11th.
As for sleep that started after midnight, here's an example of that:
"dateTime": "2016-07-23",
"value": "00:30"
Sleep started and ended on the same day, so it's still logged that day.
I think you might be using "minutesAsleep" instead of "startTime" though.
08-03-2016 20:36
08-03-2016 20:36
Ok, it might be super obvious but then how do you tell which day the sleep started on?
08-04-2016 10:56 - edited 08-04-2016 10:57
08-04-2016 10:56 - edited 08-04-2016 10:57
@ThatOneCat If you're using that endpoint then I assume if "value" returns anything equal to or less than "23:59", then the start date of sleep is the day before "dateTime".
It's a little difficult to make assumptions like that, but that's the only way I can tell using that endpoint (what if they took a nap or something late at night? ).
If you look at a specific day though, it will return the startTime with the date (which makes it easier):
"startTime": "2016-05-10T23:34:30.000"
https://api.fitbit.com/1/user/-/sleep/date/2016-05-11.json
Doesn't really help if you're trying to grab multiple days at once.