本文介绍睡眠带相关接口。
 
API 列表
 
| 请求方法 | API | 描述 | 
|---|
| GET | /v1.0/devices/{device_id}/sleep/daily-reports | 获取日睡眠报告。 | 
| GET | /v1.0/devices/{device_id}/sleep/monthly-reports | 获取月睡眠报告。 | 
| GET | /v1.0/devices/{device_id}/sleep/24h-reports | 获取 24 小时睡眠报告。 | 
| GET | /v1.0/devices/{device_id}/sleep/preview/reports | 预览睡眠报告状态。 | 
| PUT | /v1.0/devices/{device_id}/sleep/reports/{report_id} | 更新报告状态。 | 
获取日睡眠报告
 
功能描述
 
获取日睡眠报告。
 
接口地址
 
GET /v1.0/devices/{device_id}/sleep/daily-reports
 
请求参数
 
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|
| device_id | String | URI | 设备 ID。 | 是 | 
| report_time | Long | URL | 获取设备所在时区报告的时间戳(精确到秒)。 | 是 | 
返回参数
 
| 参数名 | 参数类型 | 描述 | 
|---|
| success | Boolean | 是否成功:  | 
| status | String | 状态 | 
| t | Long | 13 位标准时间戳 | 
| result | List | 返回结果 | 
Result
 
Reports
 
| 参数名 | 参数类型 | 描述 | 
|---|
| report_id | Long | 报告 ID。 | 
| data_date | Long | 报告时间,精确到秒。 | 
| start_time | Long | 睡眠起始时间,精确到秒。 | 
| duration | Int | 睡觉总时长,单位秒。 | 
| wake | Int | 清醒总时间,单位秒。 | 
| out_of_bed_duration | Int | 离床时长,单位秒。 | 
| sleep_status | Int | 睡眠状态:  | 
| avg_breath_rate | Int | 平均呼吸率。 | 
| avg_heart_rate | Int | 平均心率。 | 
| snore_number | Int | 鼾声次数。 | 
| snore_duration | Int | 鼾声总时长。 | 
| snore_high_proportion | Int | 鼾声程度为高的比例。 | 
| snore_mid_proportion | Int | 鼾声程度为中的比例。 | 
| snore_low_proportion | Int | 鼾声程度为低的比例。 | 
| snore_non_proportion | Int | 鼾声程度为无的比例。 | 
请求示例
 
GET /v1.0/devices/vedeo887723I****/sleep/daily-reports?report_time=1594887507
 
返回示例
 
{"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
}
 
错误码
 
以下为该接口常见的业务异常,更多的异常错误,参见全局错误码。
 
获取月睡眠报告
 
功能描述
 
获取月睡眠报告。
 
接口地址
 
GET /v1.0/devices/{device_id}/sleep/monthly-reports
 
请求参数
 
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|
| device_id | String | URI | 设备 ID。 | 是 | 
| report_time | Long | URL | 获取设备所在时区报告的时间戳(精确到秒)。 | 是 | 
返回参数
 
| 参数名 | 参数类型 | 描述 | 
|---|
| success | Boolean | 是否成功:  | 
| status | String | 状态 | 
| t | Long | 13 位标准时间戳 | 
| result | List | 返回结果 | 
Result
 
Reports
 
| 参数名 | 参数类型 | 描述 | 
|---|
| reportId | String | 报告 ID。 | 
| time | Integer | 时间。 | 
| pos | Integer | 周或月在指定年份的位置。例如,周接口中指定"pos": 8, 表示 2020 年的第 8 周。 | 
| year | Integer | 报告的年份。 | 
| days | Integer | 记录的天数 | 
| score | Int | 平均分数。 | 
| scoreValue | Int[] | 分数列表。 | 
| avg_sleep_time | Int | 平均睡眠时长,单位秒。 | 
| avg_fallasleep_time | Int | 平均入睡时长,单位秒。 | 
| sleep_time_value | Int[] | 实际睡眠时长列表,单位秒。 | 
| fallasleep_time_value | Int[] | 入睡时长列表,单位秒。 | 
| avg_sleep_percentage | Int | 平均睡眠效率。 | 
| avg_deepsleep_percentage | Int | 平均深睡比例。 | 
| sleep_percentage_value | Int[] | 睡眠效率列表。 | 
| deepsleep_percentage_value | Int[] | 深睡比例列表。 | 
| sleep_rule_status | Int | 睡眠规律:  | 
| start_sleep_value | List | 开始睡觉时间列表。 | 
| wakeup_value | List | 清醒时间列表。 | 
| avg_breath_rate | Int | 平均呼吸率。 | 
| breath_rate_value | Int[] | 呼吸率列表。 | 
| avg_heart_rate | Int | 平均心率。 | 
| heart_rate_value | Int[] | 心率列表。 | 
| avg_inbed_time | Int | 平均赖床时长,单位秒。 | 
| inbed_time_value | Int[] | 赖床时长列表,单位秒。 | 
| avgawake_times | Int | 平均清醒次数。 | 
| awake_times_value | Int[] | 清醒次数列表。 | 
| avg_outofbed_times | Int | 起床次数。 | 
| outofbed_times_cnt | Int | 离床次数。 | 
| outofbed_times_value | Int[] | 起床次数列表。 | 
| factors | String | 周月状态值:  | 
| score_perc | String | 分数占比状态: - 0:完美睡觉占比
 - 1:优秀睡觉占比
 - 2:一般睡觉占比
 - 3:睡觉差劲占比
 - 4:没有睡觉记录占比
 
  | 
| sleep_hour_more9days | Int | 睡眠时长超过 9 个小时的天数。 | 
| sleep_hour_less6days | Int | 睡眠时长少于 6 个小时的天数。 | 
| heartbeat_pause_days | Int | 心跳过缓天数。 | 
| apnea_days | Int | 呼吸过缓天数。 | 
| avgSnore_time | Int | 平均鼾声时长。 | 
| snore_time_value | Int[] | 鼾声时长列表。 | 
请求示例
 
GET /v1.0/devices/vedeo74882653500291/sleep/monthly-reports?report_time=1594887507
 
返回参数
 
{"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
}
 
错误码
 
以下为该接口常见的业务异常,更多的异常错误,参见全局错误码。
 
获取 24 小时睡眠报告
 
功能描述
 
获取 24 小时睡眠报告。
 
接口地址
 
GET /v1.0/devices/{device_id}/sleep/24h-reports
 
请求参数
 
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|
| device_id | String | URI | 设备 ID。 | 是 | 
| report_time | Long | URL | 获取设备所在时区报告的时间戳(精确到秒)。 | 是 | 
返回参数
 
| 参数名 | 参数类型 | 描述 | 
|---|
| success | Boolean | 是否成功:  | 
| status | String | 状态 | 
| t | Long | 13 位标准时间戳 | 
| result | List | 返回结果 | 
result 说明
 
| 参数名 | 参数类型 | 描述 | 
|---|
| report_id | Long | 报告 ID | 
| start_time | Long | 睡眠起始时间 | 
| duration | Int | 睡觉总时长 | 
| wake | Int | 清醒总时间 | 
| out_of_bed_duration | Int | 离床时长 | 
| sleep_status | Int[] | 睡眠状态 | 
| avg_breath_rate | Int | 平均呼吸率 | 
| avg_heart_rate | Int | 平均心率 | 
| snore_number | Int | 鼾声次数 | 
| snore_duration | Int | 鼾声总时长 | 
| snore_high_proportion | Int | 鼾声程度为高的比例 | 
| snore_mid_proportion | Int | 鼾声程度为中的比例 | 
| snore_low_proportion | Int | 鼾声程度为低的比例 | 
| snore_non_proportion | Int | 鼾声程度为无的比例 | 
请求示例
 
GET /v1.0/devices/vedeo8877237278/sleep/24h-reports?report_time=1594887507
 
返回示例
 
{"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
}
 
错误码
 
以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。
 
预览睡眠报告状态
 
功能描述
 
预览睡眠报告状态。
 
接口地址
 
GET /v1.0/devices/{device_id}/sleep/preview/reports
 
请求参数
 
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|
| device_id | String | URI | 设备 ID。 | 是 | 
| start_time | Long | URL | 设备所在时区开始时间的时间戳(精确到秒)。 | 是 | 
| end_time | Long | URL | 设备所在时区结束时间的时间戳(精确到秒)。 | 是 | 
返回参数
 
| 参数名 | 参数类型 | 描述 | 
|---|
| success | Boolean | 是否成功:  | 
| status | String | 状态 | 
| t | Long | 13 位标准时间戳 | 
| result | List | 返回结果 | 
Result
 
| 参数名 | 参数类型 | 描述 | 
|---|
| report_id | String | 报告 ID。 | 
| data_date | String | 查询时间,格式为yyyy-MM-dd。 | 
| read_state | Boolean | 是否已读:  | 
请求示例
 
GET /v1.0/devices/vedeo53424223/sleep/preview/reports?start_time=1590984264&end_time=1593489864
 
返回示例
 
{"result":[{"data_date": "2020-08-03","read_state": true,"report_id": 1355686}],"t":1594979100693,"success":true,"status":"ok"
}
 
错误码
 
以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。
 
更新报告状态
 
功能描述
 
更新报告读取状态。
 
接口地址
 
PUT /v1.0/devices/{device_id}/sleep/reports/{report_id}
 
请求参数
 
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|
| device_id | String | URI | 设备 ID | 是 | 
| report_id | Long | URL | 报告 ID | 是 | 
返回参数
 
| 参数名 | 类型 | 说明 | 
|---|
| code | Integer | 错误码。 | 
| success | Boolean | 是否成功:  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Boolean | 返回结果。 | 
请求示例
 
PUT /v1.0/devices/vedeo623232/sleep/reports/10002
 
返回示例
 
 
{ "result":true, "t":1542776517323 } 
 
错误码
 
以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。