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

I need to get an API for sleep state

ANSWERED

Hello I am a college student at computer engineering department.
I want to develop an application. To do that, I need to get an API for sleep state, how can I get it?
Can I integrate the web API with Android mobile?
Is it possible to get the data as soon as the user is asleep?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

It looks like they have updated the API docs here - https://dev.fitbit.com/docs/sleep/ to include the stages data 

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

I was really excited to learn about the new Sleep Stages and other features being released soon, specified here

 

I apologize if this is a duplicate post, but I did not find one specifically asking about the API side of this new feature.  Will we be able to access Sleep Stages, in particular, from the API?  It would be extremely helpful to sleep research.  A daily statistic showing the number of minutes in each stage, perhaps, and eventually the sleep stage in the minute-by-minute sleep log would be great.

Best Answer

It's a little unclear what you're asking.  Are you looking for the new sleep stages feature that was just announced? (here)  Or are you asking how to get sleep data in general?  If you're referring to the new sleep stages feature, it's not available on the API yet.  I actually asked a question about it recently, which hasn't been answered yet (here).

 

If you're asking how to get sleep data in general, I would suggest reading the guide in the API documentation (here) and looking at the available 3rd-party oAuth libraries that Fitbit has suggested (listed here).  Yes, you can integrate the web API with an Android app - although not listed in the 3rd-party libraries I linked, there are some samples on Github and some discussions in the community forum here on how best to do it.

 

Your last question depends on what you mean by 'as soon as'.  It takes the Fitbit device awhile to determine if the person is actually asleep (not sure how long exactly as I haven't tested it, but I believe the minimum for a nap is about an hour, so I would guess that if I had to make a guess), so that is one restriction.  The second is that the only way for you to get Fitbit data is through the API, which is through the web.  So, in order to get the sleep data you would need to have the Fitbit device sync it to the web first, and then you can access it.  You can turn 'all-day sync' on, which is a setting on the Fitbit device (and it uses a lot of battery, in my experience), but all-day sync does the sync every 15 minutes.  So it's unlikely that you'll know immediately if they fall asleep, even if the Fitbit device did know the user was asleep right away.

 

Best Answer

@rMirage Sorry, I actually looked into that when you first posted your question since I was also curious about sleep stages, but I didn't get a solid enough answer to be able to reply. Robot Embarassed

 

@rMirage @Hyoyoung My guess would be that sleep stages will be available through the API at some point (either through the existing sleep endpoint or a variation of it), but I'm waiting for the feature to launch to be able to confirm.

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

It looks like they have updated the API docs here - https://dev.fitbit.com/docs/sleep/ to include the stages data 

Best Answer
0 Votes