v1

latestOpenAPI 3.1.02026-07-136587849.3 KB
Queries / Sleep

Get Sleep

This endpoint returns sleep data including different sleep stages that represent the various phases of sleep a person goes through during a sleep cycle. Each stage is characterized by distinct physiological and neurological patterns.

The different sleep stages are:

  • awake: The state of being fully conscious and alert.
  • sleeping: A general term for being in a state of sleep.
  • out_of_bed: The state when a person is not in bed, possibly indicating a brief interruption in sleep.
  • light: A stage of sleep where the body begins to relax, and the heart rate slows down. It is easier to wake up from this stage.
  • deep: A restorative stage of sleep where the body repairs and regrows tissues, builds bone and muscle, and strengthens the immune system.
  • rem: Rapid Eye Movement sleep, a stage where dreaming occurs, and the brain is very active. It plays a role in memory consolidation and mood regulation.
  • awake_in_bed: The state of being awake while still in bed, often occurring before falling asleep or after waking up.
  • nap: A short sleep, typically taken during the day, that can help improve alertness and performance.
  • unknown: A stage that cannot be classified into any of the known categories, possibly due to insufficient data or anomalies in the sleep pattern.

Sleep Attribution Date

The sleep date attribution follows two simple rules to determine which date a sleep record should be associated with:

  1. Provider Payload Date: The primary source of truth is the date provided in the payload from the sleep tracking provider. This date is used if available.

  2. End Date Rule: If the provider payload date is not available, the sleep date is attributed to the day on which the sleep session ended.

This straightforward approach ensures consistent date attribution for sleep records, regardless of when the sleep session started or ended.

Main Sleep and Nap

There are two types of sleep: main sleep and nap. There can be only one main sleep per day, which is the longest sleep period. A nap is a shorter sleep taken during the day and will have a sleep_duration_nap value.

Sleep Durations

Total sleep duration is the sum of the durations of light, deep, and REM sleep stages, while total time in bed also includes time spent awake.

total sleep = light + deep + rem
time in bed = total sleep + awake

Note that nap time is not included in the total sleep time for a day. Sleep latency refers to the estimated time from when rest begins until the first occurrence of light or deep sleep. The accuracy of sleep stages and latency depends entirely on the provider’s sensors and calculations. Sleep duration values are reported in milliseconds.

get/queries/sleeps/{sleep_id}

Path parameters

sleep_idstring required

Sleep ID

Sleep ID

Query parameters

include_stagesboolean

Include stages

Include stages

include_samplesboolean

Include samples

Include samples

Response

OK

durationinteger

Record duration

end_at_timestampstring date-time

Record end time

input_method'unknown' | 'manual' | 'device'

Data input method

modified_atstring date-time required

Modified at

provider_slugstring

Provider slugs

record_idsstring[] nullable
scoreinteger
sleep_datestring date

Calendar date for which the sleep is attributed

sleep_idstring byte
start_at_timestampstring date-time required

Record start time

user_time_offset_minutesinteger

User time offset in minutes

Example response

{
  "metrics": {
    "air_temperature": 22.73,
    "air_temperature_max": 28.55,
    "air_temperature_min": 15.27,
    "ascent": 320.29,
    "basal_body_temperature": 36.53,
    "basal_body_temperature_max": 37.03,
    "basal_body_temperature_min": 36.01,
    "bedtime_duration": 28800000,
    "blood_pressure_diastolic": 80.03,
    "blood_pressure_diastolic_max": 90.07,
    "blood_pressure_diastolic_min": 60.01,
    "blood_pressure_systolic": 120.03,
    "blood_pressure_systolic_max": 140.07,
    "blood_pressure_systolic_min": 100.01,
    "body_bone_mass": 3200,
    "body_fat": 18.53,
    "body_fat_max": 25.03,
    "body_fat_min": 12.01,
    "body_mass_index": 22.5016,
    "body_temperature": 36.73,
    "body_temperature_max": 37.55,
    "body_temperature_min": 36.13,
    "breathing_rate": 16.5016,
    "breathing_rate_max": 24.7549,
    "breathing_rate_min": 12.2534,
    "cadence": 85.5016,
    "cadence_max": 110.0049,
    "cadence_min": 60.0034,
    "calories_burned": 1650.7549,
    "calories_burned_active": 450.2516,
    "calories_burned_basal": 1200.5034,
    "calories_intake": 2100.5016,
    "descent": 280.91,
    "distance": 6500.2516,
    "distance_cycling": 15000.7549,
    "distance_running": 5000.5016,
    "distance_swimming": 1000.7549,
    "distance_walking": 3200.5034,
    "distance_wheelchair": 2800.5034,
    "duration_active": 5400000,
    "duration_high_intensity": 1200000,
    "duration_low_intensity": 9000000,
    "duration_moderate_intensity": 2400000,
    "ecg_rri": 850,
    "ecg_voltage": 1200.53,
    "elevation": 1050.73,
    "elevation_gain": 450.83,
    "elevation_loss": 380.47,
    "elevation_max": 1250.55,
    "elevation_min": 850.37,
    "floors_climbed": 12,
    "glucose": 95.654321,
    "heartrate": 90,
    "heartrate_max": 180,
    "heartrate_min": 60,
    "heartrate_resting": 70,
    "heartrate_resting_max": 85,
    "heartrate_resting_min": 60,
    "heartrate_zone0_duration": 5000,
    "heartrate_zone1_duration": 7152,
    "heartrate_zone2_duration": 25000,
    "heartrate_zone3_duration": 18170,
    "heartrate_zone4_duration": 6372,
    "heartrate_zone5_duration": 2000,
    "height": 1.7549,
    "hrv_rmssd": 45,
    "hrv_sdnn": 52,
    "latitude": 37.77492948,
    "longitude": -122.41941637,
    "pace": 3.53,
    "power": 125,
    "power_max": 125,
    "skin_temperature": 33.53,
    "skin_temperature_max": 34.27,
    "skin_temperature_min": 32.89,
    "sleep_breathing_rate": 14.27,
    "sleep_breathing_rate_max": 18.59,
    "sleep_breathing_rate_min": 10.03,
    "sleep_duration": 25200000,
    "sleep_duration_awake": 1800000,
    "sleep_duration_deep": 5400000,
    "sleep_duration_light": 12600000,
    "sleep_duration_nap": 3600000,
    "sleep_duration_rem": 3600000,
    "sleep_efficiency": 92,
    "sleep_interruptions": 2,
    "sleep_latency": 900000,
    "sleep_score": 85,
    "sleep_skin_temperature_deviation": -0.13,
    "speed": 3.2516,
    "speed_max": 8.5034,
    "speed_min": 0.5016,
    "spo2": 98.5016,
    "spo2_max": 99.5034,
    "spo2_min": 95.2516,
    "steps": 8500,
    "swimming_distance_per_stroke": 2.27,
    "swimming_lengths": 40,
    "vo2max": 45.23,
    "wakeup_latency": 600000,
    "weight": 70000.5034
  },
  "provider_slug": "strava",
  "record_ids": [
    "12345678-1234-abcd-4321-abcdef123456"
  ],
  "sleep_date": "2006-01-02",
  "stages": [
    {
      "metrics": {
        "air_temperature": 22.73,
        "air_temperature_max": 28.55,
        "air_temperature_min": 15.27,
        "ascent": 320.29,
        "basal_body_temperature": 36.53,
        "basal_body_temperature_max": 37.03,
        "basal_body_temperature_min": 36.01,
        "bedtime_duration": 28800000,
        "blood_pressure_diastolic": 80.03,
        "blood_pressure_diastolic_max": 90.07,
        "blood_pressure_diastolic_min": 60.01,
        "blood_pressure_systolic": 120.03,
        "blood_pressure_systolic_max": 140.07,
        "blood_pressure_systolic_min": 100.01,
        "body_bone_mass": 3200,
        "body_fat": 18.53,
        "body_fat_max": 25.03,
        "body_fat_min": 12.01,
        "body_mass_index": 22.5016,
        "body_temperature": 36.73,
        "body_temperature_max": 37.55,
        "body_temperature_min": 36.13,
        "breathing_rate": 16.5016,
        "breathing_rate_max": 24.7549,
        "breathing_rate_min": 12.2534,
        "cadence": 85.5016,
        "cadence_max": 110.0049,
        "cadence_min": 60.0034,
        "calories_burned": 1650.7549,
        "calories_burned_active": 450.2516,
        "calories_burned_basal": 1200.5034,
        "calories_intake": 2100.5016,
        "descent": 280.91,
        "distance": 6500.2516,
        "distance_cycling": 15000.7549,
        "distance_running": 5000.5016,
        "distance_swimming": 1000.7549,
        "distance_walking": 3200.5034,
        "distance_wheelchair": 2800.5034,
        "duration_active": 5400000,
        "duration_high_intensity": 1200000,
        "duration_low_intensity": 9000000,
        "duration_moderate_intensity": 2400000,
        "ecg_rri": 850,
        "ecg_voltage": 1200.53,
        "elevation": 1050.73,
        "elevation_gain": 450.83,
        "elevation_loss": 380.47,
        "elevation_max": 1250.55,
        "elevation_min": 850.37,
        "floors_climbed": 12,
        "glucose": 95.654321,
        "heartrate": 90,
        "heartrate_max": 180,
        "heartrate_min": 60,
        "heartrate_resting": 70,
        "heartrate_resting_max": 85,
        "heartrate_resting_min": 60,
        "heartrate_zone0_duration": 5000,
        "heartrate_zone1_duration": 7152,
        "heartrate_zone2_duration": 25000,
        "heartrate_zone3_duration": 18170,
        "heartrate_zone4_duration": 6372,
        "heartrate_zone5_duration": 2000,
        "height": 1.7549,
        "hrv_rmssd": 45,
        "hrv_sdnn": 52,
        "latitude": 37.77492948,
        "longitude": -122.41941637,
        "pace": 3.53,
        "power": 125,
        "power_max": 125,
        "skin_temperature": 33.53,
        "skin_temperature_max": 34.27,
        "skin_temperature_min": 32.89,
        "sleep_breathing_rate": 14.27,
        "sleep_breathing_rate_max": 18.59,
        "sleep_breathing_rate_min": 10.03,
        "sleep_duration": 25200000,
        "sleep_duration_awake": 1800000,
        "sleep_duration_deep": 5400000,
        "sleep_duration_light": 12600000,
        "sleep_duration_nap": 3600000,
        "sleep_duration_rem": 3600000,
        "sleep_efficiency": 92,
        "sleep_interruptions": 2,
        "sleep_latency": 900000,
        "sleep_score": 85,
        "sleep_skin_temperature_deviation": -0.13,
        "speed": 3.2516,
        "speed_max": 8.5034,
        "speed_min": 0.5016,
        "spo2": 98.5016,
        "spo2_max": 99.5034,
        "spo2_min": 95.2516,
        "steps": 8500,
        "swimming_distance_per_stroke": 2.27,
        "swimming_lengths": 40,
        "vo2max": 45.23,
        "wakeup_latency": 600000,
        "weight": 70000.5034
      }
    }
  ]
}