[GET] Get Average Stats
사용자의 특정 기간 내 수면 메트릭들의 평균을 확인할 수 있습니다. 현재 100일까지 조회 가능합니다.
Request
URL
GET
https://api.asleep.ai/data/v1/users/{user_id}/average-stats
Header
Field | Type | Required | Default | Description |
---|---|---|---|---|
x-api-key | String | O | - | API Key |
timezone | String | X | UTC | 분석 결과의 시간대를 해당 timezone으로 변경해서 반환 예. UTC, Asia/Seoul |
Path parameter
Field | Type | Required | Description |
---|---|---|---|
user_id | String | O | 데이터를 요청하고자 하는 사용자의 id |
Query string
Field | Type | Required | Default | Description |
---|---|---|---|---|
start_date | String | O | - | 평균을 확인하고자 하는 기간의 시작 시간 |
end_date | String | O | - | 평균을 확인하고자 하는 기간의 종료 시간 |
Example
curl "https://api.asleep.ai/data/v1/users/{user_id}/average-stats?start_date=2023-10-20&end_date=2023-10-30" -XGET \
-H "x-api-key: <YOUR_API_KEY>"
Response
200 OK
- 조회 성공
{
"detail": "OK",
"result": {
"period": {
"timezone": "UTC",
"start_date": "2025-01-01",
"end_date": "2025-01-05"
},
"peculiarities": ["NO_BREATHING_STABILITY"],
"average_stats": {
"start_time": "02:54:01",
"end_time": "07:28:03",
"sleep_time": "03:10:30",
"wake_time": "07:17:44",
"sleep_latency": 990,
"wakeup_latency": 714,
"time_in_bed": 16381,
"time_in_sleep_period": 14658,
"time_in_sleep": 14154,
"time_in_wake": 504,
"time_in_light": 6492,
"time_in_deep": 3270,
"time_in_rem": 4392,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 53,
"time_in_no_snoring": 18270,
"sleep_efficiency": 0.864,
"wake_ratio": 0.034,
"sleep_ratio": 0.966,
"light_ratio": 0.443,
"deep_ratio": 0.223,
"rem_ratio": 0.3,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.004,
"no_snoring_ratio": 0.996,
"breathing_index": null,
"waso_count": 7,
"longest_waso": 228,
"unstable_breath_count": null,
"sleep_cycle_count": 3,
"snoring_count": 2
},
"never_slept_sessions": [],
"slept_sessions": [
{
"id": "20250101173000_biuw0",
"created_timezone": "Asia/Seoul",
"start_time": "2025-01-01T17:30:00+00:00",
"end_time": "2025-01-01T22:37:23+00:00",
"completed_time": "2025-01-01T22:37:25+00:00",
"sleep_time": "2025-01-01T17:30:00+00:00",
"wake_time": "2025-01-01T22:32:23+00:00",
"sleep_latency": 0,
"wakeup_latency": 300,
"light_latency": 0,
"deep_latency": 390,
"rem_latency": 3840,
"time_in_bed": 18443,
"time_in_sleep_period": 18120,
"time_in_sleep": 17910,
"time_in_wake": 210,
"time_in_light": 7020,
"time_in_deep": 4410,
"time_in_rem": 6480,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 60,
"time_in_no_snoring": 18060,
"sleep_efficiency": 0.97,
"sleep_ratio": 0.99,
"wake_ratio": 0.01,
"light_ratio": 0.39,
"deep_ratio": 0.24,
"rem_ratio": 0.36,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.0,
"no_snoring_ratio": 1.0,
"breathing_pattern": null,
"breathing_index": null,
"waso_count": 7,
"longest_waso": 30,
"sleep_cycle_count": 4,
"sleep_cycle": 4522,
"unstable_breath_count": null,
"snoring_count": 2
},
{
"id": "20250102180002_1it7v",
"created_timezone": "Asia/Seoul",
"start_time": "2025-01-02T18:00:02+00:00",
"end_time": "2025-01-02T23:05:06+00:00",
"completed_time": "2025-01-02T23:05:07+00:00",
"sleep_time": "2025-01-02T18:30:02+00:00",
"wake_time": "2025-01-02T23:05:06+00:00",
"sleep_latency": 1800,
"wakeup_latency": 0,
"light_latency": 0,
"deep_latency": 510,
"rem_latency": 3750,
"time_in_bed": 18304,
"time_in_sleep_period": 16500,
"time_in_sleep": 15660,
"time_in_wake": 840,
"time_in_light": 8460,
"time_in_deep": 3690,
"time_in_rem": 3510,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 30,
"time_in_no_snoring": 16470,
"sleep_efficiency": 0.86,
"sleep_ratio": 0.95,
"wake_ratio": 0.05,
"light_ratio": 0.52,
"deep_ratio": 0.22,
"rem_ratio": 0.21,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.0,
"no_snoring_ratio": 1.0,
"breathing_pattern": null,
"breathing_index": null,
"waso_count": 10,
"longest_waso": 240,
"sleep_cycle_count": 3,
"sleep_cycle": 5490,
"unstable_breath_count": null,
"snoring_count": 1
},
{
"id": "20250103180002_91khj",
"created_timezone": "Asia/Seoul",
"start_time": "2025-01-03T18:00:02+00:00",
"end_time": "2025-01-03T23:05:14+00:00",
"completed_time": "2025-01-03T23:05:15+00:00",
"sleep_time": "2025-01-03T18:00:02+00:00",
"wake_time": "2025-01-03T23:05:14+00:00",
"sleep_latency": 0,
"wakeup_latency": 0,
"light_latency": 0,
"deep_latency": 390,
"rem_latency": 3360,
"time_in_bed": 18312,
"time_in_sleep_period": 18300,
"time_in_sleep": 17220,
"time_in_wake": 1080,
"time_in_light": 8910,
"time_in_deep": 3150,
"time_in_rem": 5160,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 0,
"time_in_no_snoring": 18300,
"sleep_efficiency": 0.94,
"sleep_ratio": 0.94,
"wake_ratio": 0.06,
"light_ratio": 0.49,
"deep_ratio": 0.17,
"rem_ratio": 0.28,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.0,
"no_snoring_ratio": 1.0,
"breathing_pattern": null,
"breathing_index": null,
"waso_count": 8,
"longest_waso": 720,
"sleep_cycle_count": 3,
"sleep_cycle": 5940,
"unstable_breath_count": null,
"snoring_count": 0
},
{
"id": "20250104180001_z8tn9",
"created_timezone": "Asia/Seoul",
"start_time": "2025-01-04T18:00:01+00:00",
"end_time": "2025-01-04T20:27:03+00:00",
"completed_time": "2025-01-04T20:27:05+00:00",
"sleep_time": "2025-01-04T18:00:01+00:00",
"wake_time": "2025-01-04T19:32:33+00:00",
"sleep_latency": 0,
"wakeup_latency": 3270,
"light_latency": 0,
"deep_latency": 690,
"rem_latency": 3630,
"time_in_bed": 8822,
"time_in_sleep_period": 5520,
"time_in_sleep": 5370,
"time_in_wake": 150,
"time_in_light": 2100,
"time_in_deep": 1680,
"time_in_rem": 1590,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 30,
"time_in_no_snoring": 5490,
"sleep_efficiency": 0.61,
"sleep_ratio": 0.97,
"wake_ratio": 0.03,
"light_ratio": 0.38,
"deep_ratio": 0.3,
"rem_ratio": 0.29,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.01,
"no_snoring_ratio": 0.99,
"breathing_pattern": null,
"breathing_index": null,
"waso_count": 3,
"longest_waso": 60,
"sleep_cycle_count": 1,
"sleep_cycle": 5190,
"unstable_breath_count": null,
"snoring_count": 1
},
{
"id": "20250105180002_s3dh3",
"created_timezone": "Asia/Seoul",
"start_time": "2025-01-05T18:00:02+00:00",
"end_time": "2025-01-05T23:00:26+00:00",
"completed_time": "2025-01-05T23:00:27+00:00",
"sleep_time": "2025-01-05T18:52:32+00:00",
"wake_time": "2025-01-05T23:00:26+00:00",
"sleep_latency": 3150,
"wakeup_latency": 0,
"light_latency": 0,
"deep_latency": 450,
"rem_latency": 3750,
"time_in_bed": 18024,
"time_in_sleep_period": 14850,
"time_in_sleep": 14610,
"time_in_wake": 240,
"time_in_light": 5970,
"time_in_deep": 3420,
"time_in_rem": 5220,
"time_in_stable_breath": null,
"time_in_unstable_breath": null,
"time_in_snoring": 90,
"time_in_no_snoring": 14760,
"sleep_efficiency": 0.81,
"sleep_ratio": 0.98,
"wake_ratio": 0.02,
"light_ratio": 0.4,
"deep_ratio": 0.23,
"rem_ratio": 0.35,
"stable_breath_ratio": null,
"unstable_breath_ratio": null,
"snoring_ratio": 0.01,
"no_snoring_ratio": 0.99,
"breathing_pattern": null,
"breathing_index": null,
"waso_count": 6,
"longest_waso": 90,
"sleep_cycle_count": 2,
"sleep_cycle": 7155,
"unstable_breath_count": null,
"snoring_count": 3
}
]
}
}
Body (result field)
Field | Type | Description |
---|---|---|
period | Period Object | 타임존 (Timezone List) |
peculiarities | List | 수면 세션들의 평균을 구할 때 특이사항.NO_BREATHING_STABILITY : Breathing_stability에 대한 분석은 더 이상 B2B로 제공하지 않아 V3 기준 모든 세션에 해당 peculiarities가 존재합니다. 향후 삭제할 예정입니다. |
average_stats | Average Stats Object? | slept_sessions의 수면 메트릭들의 평균들을 가지는 객체 |
never_slept_sessions | List of Never Slept Session Object | 세션 측정시간 동안 전혀 잠을 자지 않았다고 판단 되는 세션들의 목록 |
slept_sessions | List of Slept Session Object | 세션 측정시간 동안 잠을 잤다고 판단 되는 세션들의 목록 |
Period Object
Field | Type | Description |
---|---|---|
timezone | String | 요청한 타임존 예. UTC, Asia/Seoul |
start_date | String(YYYY-MM-DD ) | 요청한 시작 시간 |
end_date | String (YYYY-MM-DD ) | 요청한 종료 시간 |
Average Stats Object
Field | Type | Description |
---|---|---|
start_time | String(hh:mm:ss ) | 세션 시작 시각 |
end_time | String(hh:mm:ss ) | 세션 종료 시각 |
sleep_time | String (hh:mm:ss ) | 잠들때까지 걸린 시각 |
wake_time | String (hh:mm:ss ) | 잠에서 깨어난 시각 |
sleep_latency | Int | 잠들때까지 걸린 시각 |
wakeup_latency | Int | 잠에서 깨어난 후 수면 측정을 종료하기까지 걸린 시간 |
time_in_bed | Int | 수면 측정 시작 시각부터 수면 측정 종료 시각 까지의 시간 |
time_in_sleep_period | Int | 수면 측정 시간 중 수면 측정 시작으로부터 잠들기 까지 걸린 시간과 잠에서 깨어난 후로부터 수면 측정을 종료하기까지 걸린 시간을 제외한 시간 (time_in_bed - sleep_latency - wakeup_latency) |
time_in_sleep | Int | 수면 측정 시간 중 실제로 수면 중이었던 시간 이 시간이 deep, light, rem의 3단계로 구분됨 |
time_in_wake | Int | 수면 도중에 깬 시간 |
time_in_light | Int? | 수면 단계가 light 로 진행된 총 시간 |
time_in_deep | Int? | 수면 단계가 deep로 진행된 총 시간 |
time_in_rem | Int? | 수면 단계가 rem 으로 진행된 총 시간 |
time_in_snoring | Int? | 코골이가 발생한 총 시간 |
time_in_no_snoring | Int? | 코골이가 발생하지 않은 총 시간 |
sleep_efficiency | float(0~1 범위 소수점 둘째자리 ) | 수면 측정 시간 중 실제로 잠든 시간의 비율 |
wake_ratio | float(0~1 범위 소수점 둘째자리 ) | 수면 단계 도중 중간에 깬 시간의 비율 |
sleep_ratio | float(0~1 범위 소수점 둘째자리 ) | 수면 단계 도중 깨지 않고 잔 시간의 비율 |
light_ratio | float(0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 light 수면의 비율 |
deep_ratio | float(0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 deep 수면의 비율 |
rem_ratio | float(0~1 범위 소수점 둘째자리 )? | rem sleep 비율 |
snoring_ratio | float(0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 코골이었던 시간의 비율 |
no_snoring_ratio | float(0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 코골이가 아니었던 시간의 비율 |
waso_count | Int? | 수면 구간 중 wake가 발생한 횟수 |
longest_waso | Int? | 수면 구간 중 가장 긴 wake의 시간 |
sleep_cycle_count | Int? | 수면 주기의 횟수 |
snoring_count | Int? | 코골이 구간의 발생한 횟수 |
Never Slept Session Object
Field | Type | Description |
---|---|---|
id | String | session id |
start_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 시작 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
end_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 종료 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
completed_time | String(YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 분석 완료 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
Slept Session Object
Field | Type | Description |
---|---|---|
id | String | session id |
created_timezone | String | 세션이 생성된 타임존 (Timezone List) |
start_time | String(YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 종료 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
end_time | String(YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 종료 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
completed_time | String(YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 분석 완료 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
sleep_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm )? | 수면 측정 시작 후 잠들기 까지 걸린 시간 |
wake_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm )? | 잠에서 깨어난 시각 |
sleep_latency | int (seconds )? | 잠들때까지 걸린 시각 |
wakeup_latency | int (seconds )? | 잠에서 깨어난 후 수면 측정을 종료하기까지 걸린 시간 |
sleep_efficiency | float (0~1 범위 소수점 둘째자리 ) | 수면 측정 시간 중 실제로 잠든 시간의 비율 |
light_latency | int(seconds )? | 첫 수면 시작으로부터 첫 번째 light가 발생하기까지의 시간 |
deep_latency | int(seconds )? | 첫 수면 시작으로부터 첫 번째 deep이 발생하기까지의 시 |
rem_latency | int(seconds )? | 첫 수면 시작으로부터 첫 번째 rem이 발생하기까지의 시간 |
time_in_bed | int (seconds ) | 수면 측정 시작 시각부터 수면 측정 종료 시각 까지의 시간 |
time_in_sleep_period | int (seconds ) | 수면 측정 시간 중 수면 측정 시작으로부터 잠들기 까지 걸린 시간과 잠에서 깨어난 후로부터 수면 측정을 종료하기까지 걸린 시간을 제외한 시간 (time_in_bed - sleep_latency - wakeup_latency) |
time_in_sleep | int (seconds ) | 수면 측정 시간 중 실제로 수면 중이었던 시간 이 시간이 deep, light, rem의 3단계로 구분됨 |
time_in_wake | int (seconds ) | 수면 도중에 깬 시간 |
time_in_rem | int (seconds )? | 수면 단계가 rem 으로 진행된 총 시간 |
time_in_light | int (seconds )? | 수면 단계가 light 로 진행된 총 시간 |
time_in_deep | int (seconds )? | 수면 단계가 deep로 진행된 총 시간 |
time_in_snoring | int (seconds )? | 코골이가 발생한 총 시간 |
time_in_no_snoring | int (seconds )? | 코골이가 발생하지 않은 총 시간 |
wake_ratio | float (0~1 범위 소수점 둘째자리 ) | 수면 단계 도중 중간에 깬 시간의 비율 |
sleep_ratio | float (0~1 범위 소수점 둘째자리 ) | 수면 단계 도중 깨지 않고 잔 시간의 비율 |
light_ratio | float (0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 light 수면의 비율 |
deep_ratio | float (0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 deep 수면의 비율 |
rem_ratio | float (0~1 범위 소수점 둘째자리 )? | rem sleep 비율 |
snoring_ratio | float (0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 코골이었던 시간의 비율 |
no_snoring_ratio | float (0~1 범위 소수점 둘째자리 )? | 수면 단계 도중 코골이가 아니었던 시간의 비율 |
waso_count | int? | 수면 구간 중 wake가 발생한 횟수 |
longest_waso | int(seconds )? | 수면 구간 중 가장 긴 wake의 시간 |
sleep_cycle_count | int? | 수면 주기의 횟수 |
sleep_cycle | int(seconds )? | 수면 주기 1회당 평균 시간 |
snoring_count | int? | 코골이 구간이 발생한 횟수 |
400 Bad Request
- 조회 가능한 기간을 넘어 갔거나,
start_date
또는end_date
의 날짜 형식이 잘못되었을 경우
{
"detail": "The period should be less than or equal to 100 days"
}
404 Not Found
user_id
에 해당되는 사용자가 존재하지 않는 경우
{
"detail": "Unable to find the user of id {user_id}"
}
Updated 11 days ago