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

Sleepsummary data

ANSWERED
You have the API. We are using it for our research. 
There is Sleep API https://dev.fitbit.com/build/reference/web-api/sleep/get-sleep-log-by-date/ that sends us the sleep data for a specific day.
 
User 1 slept last night but with interruptions. There were the following sleeps:
Sleep 1. 22:00 - 04:00 
Sleep 2. 05:00 - 09:00 
 
The GET-sleep-log-by-date API sends us the summary for the night like in this example:
{
    "summary": {
        "id": 1337,
        "updated_at": "timestamp",
        "created_at": "timestamp",
        "user": "email_example",
        "totaltimeinbed": 344,
        "totalminutesasleep": 318,
        "totalsleeprecords": 2,
        "deep": 74,
        "wake": 26,
        "rem": 63,
        "light": 181
    },
We see that we get for sleep 1 and sleep 2 the same replies from API, the deep, wake, rem, light are the same. 
 
How can we get the reply from API that will have specific answers in this summary for specific sleep part?
 
We have them in levels_data but not in summary.
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @EleonoraPDA 

The output you provided is a little different than the default for the Get Sleep Log by Date endpoint.  If you call the endpoint directly, you should see the individual sleep periods and their data listed separately, followed by the summary of all values added up for the 24 hour period.   For example, the individual sleep periods summary would look like this

        "summary": {
          "deep": {
            "count": 5,
            "minutes": 104,
            "thirtyDayAvgMinutes": 69
          },
          "light": {
            "count": 32,
            "minutes": 205,
            "thirtyDayAvgMinutes": 202
          },
          "rem": {
            "count": 11,
            "minutes": 75,
            "thirtyDayAvgMinutes": 87
          },
          "wake": {
            "count": 30,
            "minutes": 78,
            "thirtyDayAvgMinutes": 55
          }
        }

And, the summary for the entire day when adding up all of the individual sleep periods would look like this  

  "summary": {
    "stages": {
      "deep": 104,
      "light": 205,
      "rem": 75,
      "wake": 78
    },
    "totalMinutesAsleep": 384,
    "totalSleepRecords": 1,
    "totalTimeInBed": 462
  }

 

Based on the names, it appears the values you see are for the 24 hour period and not the individual sleep periods for the day.  If you are not seeing the results for the individual sleep periods, check with the person who wrote the code to retrieve the data to make certain they are accounting for multiple sleep periods in a single day.

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

View best answer in original post

Best Answer
1 REPLY 1

Hi @EleonoraPDA 

The output you provided is a little different than the default for the Get Sleep Log by Date endpoint.  If you call the endpoint directly, you should see the individual sleep periods and their data listed separately, followed by the summary of all values added up for the 24 hour period.   For example, the individual sleep periods summary would look like this

        "summary": {
          "deep": {
            "count": 5,
            "minutes": 104,
            "thirtyDayAvgMinutes": 69
          },
          "light": {
            "count": 32,
            "minutes": 205,
            "thirtyDayAvgMinutes": 202
          },
          "rem": {
            "count": 11,
            "minutes": 75,
            "thirtyDayAvgMinutes": 87
          },
          "wake": {
            "count": 30,
            "minutes": 78,
            "thirtyDayAvgMinutes": 55
          }
        }

And, the summary for the entire day when adding up all of the individual sleep periods would look like this  

  "summary": {
    "stages": {
      "deep": 104,
      "light": 205,
      "rem": 75,
      "wake": 78
    },
    "totalMinutesAsleep": 384,
    "totalSleepRecords": 1,
    "totalTimeInBed": 462
  }

 

Based on the names, it appears the values you see are for the 24 hour period and not the individual sleep periods for the day.  If you are not seeing the results for the individual sleep periods, check with the person who wrote the code to retrieve the data to make certain they are accounting for multiple sleep periods in a single day.

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