API Reference

Sleep

84 views 0

The Sleep resource are segments of sleep that occur during a specific period of time.

Overview

Property Type Description
code String The id of the sleep measurement
user_code String The global Id of the user
day Date The day the sleep was recorded. The day of the end_time is considered
start_time Datetime with Timezone The original start date and time of the sleep segment in UTC time
end_time Datetime with Timezone The original end date and time of the sleep segment in UTC time
source String The source service for the measurement, where it was created
main_sleep Boolean A boolean value indicating if this sleep was the main sleep of the day
time_asleep Number The time asleep during the segment (in minutes)
time_awake Number The time awake during the segment (in minutes)
efficiency Number The efficiency score
time_to_fall_asleep Number The number of minutes it took to fall asleep
time_after_wakeup Number The number of minutes in bed after waking up
time_in_bed Number The total number of minutes spend in bed
created_at Datetime with Timezone The time the sleep was created on the ZivaCare API server
updated_at Datetime with Timezone The time the sleep was updated on the ZivaCare API server

Example

GET https://api.zivacare.com/api/v2/human/sleeps?access_token=demo
{
  "sleeps": [
    {
      "code": "758ed613-b9d3-4ce6-8573-b7777aadd54a",
      "day": "2015-01-01",
      "start_time": "2014-09-16 15:52:01+00",
      "end_time": "2014-09-16 15:52:01+00",
      "main_sleep": true,
      "time_asleep": 300,
      "source": "fitbit", 
      "time_awake": 1,
      "efficiency": 11.20,
      "time_to_fall_asleep": 11.11,
      "time_after_wakeup": 11.00,
      "user_code": "e231e984-2209-4a10-b634-2257b89c200f",
      "created_at": "2015-04-07 17:48:40+00",
      "updated_at": "2015-05-07 14:21:11+00"
    }
 ], 
 "total": 1
}

curl -X POST -H 'Content-Type: application/json' https://api.zivacare.com/api/v2/human/sleeps?access_token=demo -d '{ 
  "day": "2014-09-16T00:00:00+0000",
  "start_time": "2014-09-16T15:52:01+0000",
  "end_time": "2014-09-16T15:52:01+0000",
  "main_sleep": true,
  "time_asleep": 10,
  "time_awake": 10,
  "source": "fitbit", 
  "efficiency": 1,
  "time_to_fall_asleep": 10,
  "time_after_wakeup": 10,
  "time_in_bed": 10,
  "time_series": ""
}'

 

GET https://api.zivacare.com/api/v2/human/sleeps/daily/2014-09-16?access_token=demo
{
  "sleeps": [
    {
      "code": "758ed613-b9d3-4ce6-8573-b7777aadd54a",
      "day": "2015-01-01",
      "start_time": "2014-09-16 15:52:01+00",
      "end_time": "2014-09-16 15:52:01+00",
      "main_sleep": true,
      "time_asleep": 300,
      "source": "fitbit", 
      "time_awake": 1,
      "efficiency": 11.20,
      "time_to_fall_asleep": 11.11,
      "time_after_wakeup": 11.00,
      "user_code": "e231e984-2209-4a10-b634-2257b89c200f",
      "created_at": "2015-04-07 17:48:40+00",
      "updated_at": "2015-05-07 14:21:11+00"
    }
 ], 
 "total": 1
}
GET https://api.zivacare.com/api/v2/human/sleeps/daily/2014-09-16?access_token=demo
{
  "sleeps": [
    {
      "code": "758ed613-b9d3-4ce6-8573-b7777aadd54a",
      "day": "2015-01-01",
      "start_time": "2014-09-16 15:52:01+00",
      "end_time": "2014-09-16 15:52:01+00",
      "main_sleep": true,
      "time_asleep": 300,
      "source": "fitbit", 
      "time_awake": 1,
      "efficiency": 11.20,
      "time_to_fall_asleep": 11.11,
      "time_after_wakeup": 11.00,
      "user_code": "e231e984-2209-4a10-b634-2257b89c200f",
      "created_at": "2015-04-07 17:48:40+00",
      "updated_at": "2015-05-07 14:21:11+00"
    }
 ], 
 "total": 1
}
GET https://api.zivacare.com/api/v2/human/sleeps/period/2014-01-01/2015-01-01?access_token=demo

 

{
  "sleeps": [
    {
      "code": "758ed613-b9d3-4ce6-8573-b7777aadd54a",
      "day": "2015-01-01",
      "start_time": "2014-09-16 15:52:01+00",
      "end_time": "2014-09-16 15:52:01+00",
      "main_sleep": true,
      "time_asleep": 300,
      "source": "fitbit", 
      "time_awake": 1,
      "efficiency": 11.20,
      "time_to_fall_asleep": 11.11,
      "time_after_wakeup": 11.00,
      "user_code": "e231e984-2209-4a10-b634-2257b89c200f",
      "created_at": "2015-04-07 17:48:40+00",
      "updated_at": "2015-05-07 14:21:11+00"
    }
 ], 
 "total": 1
}
GET https://api.zivacare.com/api/v2/human/sleeps/758ed613-b9d3-4ce6-8573-b7777aadd54a?access_token=demo
{
  "sleep": 
    {
      "code": "758ed613-b9d3-4ce6-8573-b7777aadd54a",
      "day": "2015-01-01",
      "start_time": "2014-09-16 15:52:01+00",
      "end_time": "2014-09-16 15:52:01+00",
      "main_sleep": true,
      "time_asleep": 300,
      "source": "fitbit", 
      "time_awake": 1,
      "efficiency": 11.20,
      "time_to_fall_asleep": 11.11,
      "time_after_wakeup": 11.00,
      "user_code": "e231e984-2209-4a10-b634-2257b89c200f",
      "created_at": "2015-04-07 17:48:40+00",
      "updated_at": "2015-05-07 14:21:11+00"
    }
}

curl -X PUT -H 'Content-Type: application/json' https://api.zivacare.com/api/v2/human/sleeps/758ed613-b9d3-4ce6-8573-b7777aadd54a?access_token=demo -d '{ 
  "day": "2014-09-16T00:00:00+0000",
  "start_time": "2014-09-16T15:52:01+0000",
  "end_time": "2014-09-16T15:52:01+0000",
  "main_sleep": true,
  "time_asleep": 10,
  "time_awake": 10,
  "source": "fitbit", 
  "efficiency": 1,
  "time_to_fall_asleep": 10,
  "time_after_wakeup": 10,
  "time_in_bed": 10,
  "time_series": ""
}'

Was this helpful?

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close