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

What is the reason for the difference in value for total Sleep in the Fitbit App and the API

ANSWERED

We have been consistently seeing a difference in the total sleep minutes between the value showing in Fitbit App and the value returned by the API. What is the reason for this ? 

Image from iOS.jpg

 

{
"stages" : {
"deep" : 84,
"light" : 281,
"rem" : 92,
"wake" : 70
},
"totalMinutesAsleep" : 507,
"totalSleepRecords" : 1,
"totalTimeInBed" : 527,
"awakeCount" : 1,
"awakeDuration" : 4,
"awakeningsCount" : 14,
"dateOfSleep" : "2020-02-07",
"duration" : 31620000,
"efficiency" : 96,
"endTime" : "2020-02-07T07:51:00.000",
"isMainSleep" : true,
"logId" : 25792601434.0,
"minutesAfterWakeup" : 0,
"minutesAsleep" : 507,
"minutesAwake" : 20,
"minutesToFallAsleep" : 0,
"restlessCount" : 13,
"restlessDuration" : 16,
"startTime" : "2020-02-06T23:04:00.000",
"timeInBed" : 527,
"updatedAt" : ISODate("2020-02-06T23:07:48.424Z")
}
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @developerGTC 

 

I understand how the sleep stats can be confusing.   We're hoping to update the documentation with more clarification.   In the meantime, let see if information helps explain the data you're seeing.

 

The time, 7 hr and 37 mins, represents the time the person was asleep or in sleep stages deep, light and rem.  The minutes you have in each sleep stage is 

deep = 84

light = 281

rem = 92

wake = 70

 

If you add up all of these values, you'll receive 527 minutes which equals the total time in bed.  The wake period represent the total time awake.  This includes before & after you fall asleep, and any short wake periods that occur through out the night.   If you sum the time in deep, rem or light together, OR subtract the wake from the total time in bed, you get 457 minutes (527 - 70 = 457).  457 minutes is 7 hr and 37 min.

 

Best,

Gordon

 

 

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
6 REPLIES 6

Hi @developerGTC 

 

I understand how the sleep stats can be confusing.   We're hoping to update the documentation with more clarification.   In the meantime, let see if information helps explain the data you're seeing.

 

The time, 7 hr and 37 mins, represents the time the person was asleep or in sleep stages deep, light and rem.  The minutes you have in each sleep stage is 

deep = 84

light = 281

rem = 92

wake = 70

 

If you add up all of these values, you'll receive 527 minutes which equals the total time in bed.  The wake period represent the total time awake.  This includes before & after you fall asleep, and any short wake periods that occur through out the night.   If you sum the time in deep, rem or light together, OR subtract the wake from the total time in bed, you get 457 minutes (527 - 70 = 457).  457 minutes is 7 hr and 37 min.

 

Best,

Gordon

 

 

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

Wonderful, so to put it short, the app displays the total time minus the wake time.  

 

Thanks!  

Best Answer
0 Votes

Thanks for the explanation, Gordon. However, what is the totalMinutesAsleep value indicating then? I can't figure out 507 from any of those values.

Best Answer
0 Votes

@developerGTC Can you PM me the following information so that I can investigate the values you are seeing for totalMinutesAsleep?

  • The affected user's user id from which you are fetching data from
  • The endpoint you used
  • The full API response you received

I may have the answer but I just need to confirm something before clarifying.

Best Answer
0 Votes

@developerGTC Thanks for sending me that information through PM, and I can see what the issue is here.

 

Based on the endpoint you used, it appears that you are using a deprecated sleep endpoint that is no longer supported. We now use v1.2 for sleep endpoints as this now includes a new algorithm to calculate sleep stages. I recommend making the changes in your application to call the new version of the sleep endpoints to see the correct totals.

 

For example, when I use the v1.2 sleep endpoint to fetch your sleep data from 2020-02-07 (the one showing 507 totalMinutesAsleep), I get this response:

    },
      "logId": 25792601434,
      "minutesAfterWakeup": 0,
      "minutesAsleep": 457,
      "minutesAwake": 70,
      "minutesToFallAsleep": 0,
      "startTime": "2020-02-06T23:04:00.000",
      "timeInBed": 527,
      "type": "stages"
    }
  ],
  "summary": {
    "stages": {
      "deep": 84,
      "light": 281,
      "rem": 92,
      "wake": 70
    },
    "totalMinutesAsleep": 457,
    "totalSleepRecords": 1,
    "totalTimeInBed": 527
  }
}

Whereas the deprecated v1 endpoint will show:

"minutesAfterWakeup":0,"minutesAsleep":507,"minutesAwake":20,"minutesToFallAsleep":0,"restlessCount":13,"restlessDuration":16,"startTime":"2020-02-06T23:04:00.000","timeInBed":527}],"summary":{"stages":{"deep":84,"light":281,"rem":92,"wake":70},"totalMinutesAsleep":507,"totalSleepRecords":1,"totalTimeInBed":527}}

As you can see between the two responses, there are different totals due to the new algorithm implemented for sleep stages.

 

I hope this clears up any confusion. Please let me know if you have any additional questions.

Best Answer
0 Votes

Had the same trouble and couldn't understand why. Thanks for explanation either

Best Answer
0 Votes