[GET] List Sessions
특정 사용자의 수면 세션 목록을 요청합니다.
Request
URL
GET
https://api.asleep.ai/data/v1/sessions
Header
Field | Type | Required | Default | Description |
---|---|---|---|---|
x-api-key | String | O | - | API Key |
x-user-id | String | O | - | 발급받은 user id |
timezone | String | X | UTC | 분석 결과의 시간대를 해당 timezone으로 변경해서 반환 예. UTC, Asia/Seoul |
Query parameter
- date_gte, date_lte, order_by 등은 session_start_time 기준
Field | Type | Required | Default | Description |
---|---|---|---|---|
date_gte | String (YYYY-MM-DD ) | X | - | Header의 timezone 기준으로 date_gte 보다 같거나 큰 세션들 반환 |
date_lte | String (YYYY-MM-DD ) | X | - | Header의 timezone 기준으로 date_lte 보다 같거나 작은 세션들 반환 |
order_by | String (ASC or DESC ) | X | DESC | DESC : 내림차순 정렬ASC : 오름차순 정렬 |
offset | Int | X | 0 | 스킵할 세션 개수 |
limit | Int (0~100 범위의 정수 ) | X | 20 | 받고 싶은 세션 개수 최대값 100 |
Example
curl "https://api.asleep.ai/data/v1/sessions?date_gte=2022-01-01&offset=10&limit=10&order_by=ASC" -XGET \
-H "x-api-key: <YOUR_API_KEY>" \
-H "x-user-id: <USER_ID>"
Response
200 OK
- 세션 목록 조회 성공
{
"detail": "OK",
"result": {
"timezone": "UTC",
"sleep_session_list": [
{
"session_id": "20250114182518_eq85p",
"state": "COMPLETE",
"session_start_time": "2025-01-14T18:25:18+00:00",
"session_end_time": "2025-01-14T22:55:55+00:00",
"created_timezone": "Asia/Seoul",
"unexpected_end_time": null,
"last_received_seq_num": 540,
"time_in_bed": 16237
},
{
"session_id": "20250113172906_1zch9",
"state": "COMPLETE",
"session_start_time": "2025-01-13T17:29:06+00:00",
"session_end_time": "2025-01-13T23:00:53+00:00",
"created_timezone": "Asia/Seoul",
"unexpected_end_time": null,
"last_received_seq_num": 661,
"time_in_bed": 19907
},
{
"session_id": "20250112180001_8sqei",
"state": "COMPLETE",
"session_start_time": "2025-01-12T18:00:01+00:00",
"session_end_time": "2025-01-12T23:03:11+00:00",
"created_timezone": "Asia/Seoul",
"unexpected_end_time": null,
"last_received_seq_num": 605,
"time_in_bed": 18190
},
{
"session_id": "20250111180000_9sk5t",
"state": "COMPLETE",
"session_start_time": "2025-01-11T18:00:00+00:00",
"session_end_time": "2025-01-11T23:05:08+00:00",
"created_timezone": "Asia/Seoul",
"unexpected_end_time": null,
"last_received_seq_num": 609,
"time_in_bed": 18308
},
{
"session_id": "20250110180001_csktb",
"state": "COMPLETE",
"session_start_time": "2025-01-10T18:00:01+00:00",
"session_end_time": "2025-01-10T23:05:08+00:00",
"created_timezone": "Asia/Seoul",
"unexpected_end_time": null,
"last_received_seq_num": 609,
"time_in_bed": 18307
}
]
}
}
Body (result field)
Field | Type | Description |
---|---|---|
timezone | String | 타임존 |
sleep_session_list | List of Sleep Session Objects | 세션 데이터 목록 |
Sleep Session Object
if state == OPEN
: session_end_time은 null
Field | Type | Description |
---|---|---|
session_id | String | session id |
state | String (OPEN ,CLOSED ,COMPLETE ) | 세션의 상태OPEN : 진행 중인 세션으로, 오디오 업로드가 가능한 상태CLOSED : 세션 종료 요청이 보내져 종료된 세션. 오디오 파일 업로드 불가능. 업로드된 수면 오디오에 대한 분석이 계속 진행중인 상태COMPLETE : 세션 종료 후 모든 수면 분석이 완료된 상태 |
session_start_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm ) | 세션 시작 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
session_end_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm )? | 세션 종료 시각 예) 2022-08-01T01:31:17+09:00 (요청 타임존이 Asia/Seoul 일 경우) |
created_timezone | String | 세션이 생성된 타임존 (Timezone List) |
unexpected_end_time | String(YYYY-MM-DDThh:mm:ss+-hh:mm )? | 비정상 세션 종료 시각. 앱 크래시 등으로 세션이 정상적으로 진행 및 종료되지 못했을 경우, 나중에 클라이언트가 unexpected 파라미터를 1로 하여 세션을 종료시킬 경우 해당 시간이 기록됨. 이 경우 end_time은 마지막까지 업로드된 오디오 파일의 순서 번호를 기준으로 계산됨. 따라서 null이 아닐 경우 비정상 세션. |
last_received_seq_num | Int? | 마지막으로 업로드 받은 오디오 파일의 순서 번호 |
time_in_bed | Int (seconds )? | 침대에 있었던 시간 |
400 Bad Request
timezone
이 잘못 들어온 경우
{
"detail": "The invalid timezone is provided"
}
Updated about 1 month ago