Sleep Band Open APIs

Last Updated on : 2023-06-20 14:53:57download

This topic describes the related interfaces of the sleep band.

API list

Request method API Description
GET /v1.0/devices/{device_id}/sleep/daily-reports Get a daily sleep report.
GET /v1.0/devices/{device_id}/sleep/monthly-reports Get a monthly sleep report.
GET /v1.0/devices/{device_id}/sleep/24h-reports Get a sleep report in the latest 24 hours.
GET /v1.0/devices/{device_id}/sleep/preview/reports Preview the sleep report status.
PUT /v1.0/devices/{device_id}/sleep/reports/{report_id} Update the sleep report status.

Get a daily sleep report

Function description

Get a daily sleep report.

API address

GET /v1.0/devices/{device_id}/sleep/daily-reports

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID. Yes
report_time Long URL Get the timestamp with precision down to seconds of the sleep report in the device’s timezone. Yes

Return parameter

Parameter name Parameter type Description
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
status String Status
t Long A 13-bit timestamp.
result List Return result.

Result

Parameter name Parameter type Description
reports List Sleep reports

Reports

Parameter name Parameter type Description
report_id Long Report ID.
data_date Long Reporting time with precision down to seconds.
start_time Long Falling asleep time with precision down to seconds.
duration Int Total sleeping time, in seconds.
wake Int Total awake time, in seconds.
out_of_bed_duration Int Duration of being out of bed, in seconds.
sleep_status Int Sleep status.
  • 0: Not connected
  • 1: Out of bed
  • 2: Awake
  • 3: Sleep
avg_breath_rate Int Average respiratory rate.
avg_heart_rate Int Average heart rate.
snore_number Int Number of snoring.
snore_duration Int Total duration of snoring.
snore_high_proportion Int The proportion of high snoring time in total sleeping time.
snore_mid_proportion Int The proportion of middle snoring time in total sleeping time.
snore_low_proportion Int The proportion of low snoring time in total sleeping time.
snore_non_proportion Int The proportion of no snoring time in total sleeping time.

Request example

GET /v1.0/devices/vedeo887723I****/sleep/daily-reports?report_time=1594887507

Return example

{
  "result": {
    "reports": [
      {
        "avg_breath_rate": 15,
        "avg_heart_rate": 56,
        "data_date": 1596577259,
        "duration": 238,
        "out_of_bed_duration": 528,
        "start_time": 1596477259,
        "wake": 205
      }
    ]
  },
  "success": true,
  "t": 1597115614003
}

Error code

The following are common service exceptions for this interface. For more exception errors, see Error code.

Error code Description
500 System error

Get a monthly sleep report

Function description

Get a monthly sleep report.

API address

GET /v1.0/devices/{device_id}/sleep/monthly-reports

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID. Yes
report_time Long URL Get the timestamp with precision down to seconds of the sleep report in the device’s timezone. Yes

Return parameter

Parameter name Parameter type Description
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
status String Status
t Long A 13-bit timestamp.
result List Return result.

Result

Parameter name Parameter type Description
reports List Sleep reports

Reports

Parameter name Parameter type Description
reportId String Report ID.
time Integer Time.
pos Integer The ordinal number of the week or month in a year. For example, "pos": 8 in the week interface indicates the eighth week in 2020.
year Integer Reporting year.
days Integer Number of recording days.
score Int Average score.
scoreValue Int[] Score list.
avg_sleep_time Int Average sleeping time, in seconds.
avg_fallasleep_time Int Average falling asleep time, in seconds.
sleep_time_value Int[] Actual sleeping time list, in seconds.
fallasleep_time_value Int[] Falling asleep time list, in seconds.
avg_sleep_percentage Int Average sleeping time proportion.
avg_deepsleep_percentage Int Average deep sleeping time proportion.
sleep_percentage_value Int[] Sleeping time proportion list.
deepsleep_percentage_value Int[] Deep sleeping time proportion list.
sleep_rule_status Int Sleep rule.
  • 0: Regular
  • 1: Irregular
start_sleep_value List List of sleep start time.
wakeup_value List Awake time list.
avg_breath_rate Int Average respiratory rate.
breath_rate_value Int[] Respiratory rate list.
avg_heart_rate Int Average heart rate.
heart_rate_value Int[] Heart rate list.
avg_inbed_time Int Average staying in bed time, in seconds.
inbed_time_value Int[] Staying in bed time list, in seconds.
avgawake_times Int Average awake number.
awake_times_value Int[] Awake number list.
avg_outofbed_times Int The average number of getting up in the night.
outofbed_times_cnt Int The number of getting up in the night.
outofbed_times_value Int[] The number list of getting up in the night.
factors String Week or month status.
  • 0: No
  • 1: Yes
score_perc String Score percentage status:
  • 0: Perfect sleeping percentage
  • 1: Excellent sleeping percentage
  • 2: Normal sleeping percentage
  • 3: Bad sleeping percentage
  • 4: No sleeping percentage
sleep_hour_more9days Int The number of days with more than 9 hours sleeping time.
sleep_hour_less6days Int The number of days with less than 6 hours sleeping time.
heartbeat_pause_days Int The number of days with bradycardia.
apnea_days Int The number of days with bradypnea.
avgSnore_time Int Average snoring time.
snore_time_value Int[] Snoring time list.

Request example

GET /v1.0/devices/vedeo74882653500291/sleep/monthly-reports?report_time=1594887507

Return parameter

{
  "result": {
    "reports": [
      {
        "apnea_days": 4,
        "avg_breath_rate": 15,
        "avg_deepsleep_percentage": 14,
        "avg_fallasleep_time": 24,
        "avg_heart_rate": 57,
        "avg_inbed_time": 55,
        "avg_outofbed_times": 5,
        "avg_sleep_percentage": 54,
        "avg_sleep_time": 297,
        "avg_snore_time": 0,
        "avgawake_times": 5,
        "awake_times_value": [
          3,
          2,
          2,
          9,
          0,
          10,
          11,
          -1,
          4,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "breath_rate_value": [
          15,
          15,
          15,
          15,
          15,
          15,
          15,
          -1,
          15,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "days": 8,
        "deepsleep_percentage_value": [
          6,
          11,
          0,
          21,
          46,
          0,
          3,
          -1,
          23,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "factors": "1,1,1,0,0",
        "fallasleep_time_value": [
          37,
          5,
          58,
          5,
          5,
          57,
          10,
          -1,
          15,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "heart_rate_value": [
          56,
          56,
          56,
          59,
          60,
          57,
          59,
          -1,
          56,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "heartbeat_pause_days": 0,
        "inbed_time_value": [
          125,
          42,
          125,
          49,
          4,
          11,
          59,
          -1,
          22,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "outofbed_times_cnt": 7,
        "outofbed_times_value": [
          2,
          1,
          2,
          9,
          0,
          9,
          10,
          -1,
          4,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "pos": 8,
        "score": 48,
        "score_perc": "0,0,6,19,75",
        "score_value": [
          54,
          48,
          34,
          61,
          36,
          32,
          45,
          -1,
          74,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "sleep_hour_less6days": 8,
        "sleep_hour_more9days": 1,
        "sleep_percentage_value": [
          34,
          85,
          13,
          58,
          98,
          38,
          40,
          -1,
          67,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "sleep_rule_status": 1,
        "sleep_time_value": [
          133,
          377,
          55,
          283,
          666,
          296,
          238,
          -1,
          328,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "snore_time_value": [
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1,
          -1
        ],
        "start_sleep_value": [
          "00:04",
          "23:43",
          "01:54",
          "00:29",
          "00:07",
          "23:54",
          "23:40",
          "",
          "23:43",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          ""
        ],
        "time": 1596211200,
        "wakeup_value": [
          "04:59",
          "06:47",
          "05:52",
          "06:06",
          "11:22",
          "05:58",
          "04:47",
          "",
          "05:48",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          ""
        ],
        "year": 2020
      }
    ]
  },
  "success": true,
  "t": 1597073472399
}

Error code

The following are common service exceptions for this interface. For more exception errors, see Error code.

Error code Description
500 System error

Get a sleep report in the latest 24 hours

Function description

Get a sleep report in the latest 24 hours.

API address

GET /v1.0/devices/{device_id}/sleep/24h-reports

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID. Yes
report_time Long URL Get the timestamp with precision down to seconds of the sleep report in the device’s timezone. Yes

Return parameter

Parameter name Parameter type Description
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
status String Status
t Long A 13-bit timestamp.
result List Return result.

Description of result

Parameter name Parameter type Description
report_id Long Report ID
start_time Long Start time of sleeping
duration Int Total sleeping time
wake Int Total awake time
out_of_bed_duration Int Duration of being out of bed
sleep_status Int[] Sleeping status.
avg_breath_rate Int Average respiratory rate.
avg_heart_rate Int Average heart rate.
snore_number Int Number of snoring.
snore_duration Int Total time of snoring.
snore_high_proportion Int The proportion of high snoring time in total sleeping time.
snore_mid_proportion Int The proportion of medium snoring time in total sleeping time.
snore_low_proportion Int The proportion of low snoring time in total sleeping time.
snore_non_proportion Int The proportion of no snoring time in total sleeping time.

Request example

GET /v1.0/devices/vedeo8877237278/sleep/24h-reports?report_time=1594887507

Return example

{
  "result": {
    "reports": [
      {
        "avg_breath_rate": 15,
        "avg_heart_rate": 56,
        "duration": 238,
        "out_of_bed_duration": 528,
        "start_time": 1596477259,
        "wake": 205
      }
    ]
  },
  "success": true,
  "t": 1597115614003
}

Error code

The following are common service exceptions for this interface. For more exception errors, see Error Codes.

Error code Description
500 System error

Preview the sleeping report status.

Function description

Preview the sleep report status.

API address

GET /v1.0/devices/{device_id}/sleep/preview/reports

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID. Yes
start_time Long URL Get the timestamp of the start time in the device’s timezone with precision down to seconds. Yes
end_time Long URL Get the timestamp with precision down to seconds of the end time in the device’s timezone. Yes

Return parameter

Parameter name Parameter type Description
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
status String Status
t Long A 13-bit timestamp.
result List Return result.

Result

Parameter name Parameter type Description
report_id String Report ID.
data_date String The query time in the format of yyyyMMdd.
read_state Boolean Whether the report has been read or not.
  • true: read
  • false: unread

Request example

GET /v1.0/devices/vedeo53424223/sleep/preview/reports?start_time=1590984264&end_time=1593489864

Return example

{
  "result": [
    {
      "data_date": "2020-08-03",
      "read_state": true,
      "report_id": 1355686
    }
  ],
  "t": 1594979100693,
  "success": true,
  "status": "ok"
}

Error code

The following are common service exceptions for this interface. For more exception errors, see Error Codes.

Error code Description
500 System error

Update the report status

Function description

Update the report reading status.

API address

PUT /v1.0/devices/{device_id}/sleep/reports/{report_id}

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID Yes
report_id Long URL Report ID Yes

Return parameter

Parameter name Data type Description
code Integer Error code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Boolean Return result.

Request example

PUT /v1.0/devices/vedeo623232/sleep/reports/10002

Return example

{ "result": true, "t": 1542776517323 }

Error code

The following are common service exceptions for this interface. For more exception errors, see Error Codes.

Error code Description
500 System error