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

No longer getting sleep data?

As of 6/16/2021 my host stopped getting sleep data. We request sleep as follows:

 

REQ:Method: GET, RequestUri: 'https://api.fitbit.com/1/user/-/sleep/date/2021-03-03.json', Version: 1.1, Content: <null>, Headers:
{
Authorization: Bearer <REDACTED>
}

 

but the returned content is:

 

RSP: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Origin
Vary: Accept-Encoding
Fitbit-Rate-Limit-Limit: 150
Fitbit-Rate-Limit-Remaining: 125
Fitbit-Rate-Limit-Reset: 571
X-Frame-Options: SAMEORIGIN
CF-Cache-Status: DYNAMIC
cf-request-id: 0acfca85b60000930ae13ea000000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
CF-RAY: 662cad1c5efd930a-SJC
Cache-Control: no-cache, private
Date: Mon, 21 Jun 2021 10:50:29 GMT
Server: cloudflare
Via: 1.1 google
Content-Language: en
Content-Type: application/json; charset=UTF-8
}
*************** RSP content: {"sleep":[],"summary":{"totalMinutesAsleep":0,"totalSleepRecords":0,"totalTimeInBed":0}}

 

The code for this area of our application hasn't been changed in years and was working fine up to 6/16/2021, although I'll be continuing to do isolated testing.

Best Answer
0 Votes
4 REPLIES 4

Hi @Kevin_H 

 

You're using a deprecated version of the Sleep API.   The current version is 1.2.   Please try this endpoint to see if the sleep data is returned.

 

https://api.fitbit.com/1.2/user/-/sleep/date/2021-03-03.json

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes
Sorry, I couldn't find my original post to update after I found the answer.
This project is a research study that's just now going live. It's quite
common for researchers to "play the home game" basically acting as
subjects, but they tend to be super non-compliant. In past projects I found
that when they started participating again my Fitbit data retrieval code
would bog the system down, so I added a 2-weeks-at-a-time throttle.
Unfortunately sleep data will never fill in, so anyone with more than 2
weeks of no sleep data would never get past the throttle.

I was aware of the 1.2 mods, I may have copied the wrong request from the
log. The specs seem to suggest that original sleep data and 1.2 data can be
returned, so we record both for secondary analyses.

Thank you for your help, and please close this thread.

Kevin Hollingshead
Research Software Engineer

*Arizona State University*
*College of Health Solutions*
*School of Nutrition and Health Promotion*
602-615-9972 (cell)
Best Answer
0 Votes

Hi @Kevin_H 

 

The devices store about 6-7 days of data.  I'd recommend reducing your throttle to maybe 4-5 days.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes
Good idea, thank you very much.

Kevin Hollingshead
Research Software Engineer

*Arizona State University*
*College of Health Solutions*
*School of Nutrition and Health Promotion*
602-615-9972 (cell)
Best Answer
0 Votes