11-13-2020 01:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-13-2020 01:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am trying to write a companion app that wakes me up after 7 hours of sleep (sleep implies any of REM, light and deep stages). At a high level, here are the APIs that I will need:
1. an API to schedule a periodic job (preferably on the companion app)
- This is needed to periodically count the hours slept. (Should be natively available)
2. an API to initiate the sleep calculation, while I am sleeping.
- This is needed to know if hours slept has reached 7. (??)
3. an API to push down a "vibrate" signal to the fitbit device.
- This is to awake me, once the hours slept has reached 7. (Haptics API seems promising)
I looked through the API reference, but I could not find anything concrete for #2. Is it possible?
11-18-2020 07:31
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



11-18-2020 07:31
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi @nishantsny
The sleep stage data is not available until the user wakes up and syncs their device with the mobile app. This data is not calculated in real time. If you need to determine when you're sleeping in real-time, then you'll need to use the heart rate and accelerometer data to determine that on your own.
Some of your other questions are related to the Device SDK, so I'm moving your question to that forum group.
Gordon
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
11-18-2020 08:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-18-2020 08:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
The Device API does now contain a basic sleep classifier, so you wouldn't need to use the companion.
https://dev.fitbit.com/blog/2020-09-10-announcing-fitbit-os-sdk-4.2/#sleep-api
11-18-2020 13:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-18-2020 13:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@JonFitbit Thanks, this looks promising. With this API, my workflow would be:
1. Poll this API every minute. Depending on the return value of the API, count the last minute towards the hours slept.
2. Once, hours slept reaches 7, push down vibrate signal to the device.
Should I do #1 on device or on companion app?
I am worried that polling every minute may impact the device battery significantly. Also, not sure if the device has enough memory to store the data structures needed for #1.

