List Multiple Sessions
You can request a list of sleep sessions for a specific user.
1. Request
1.1 URL
GET
https://api.asleep.ai/data/v1/sessions
1.2 Header
Field | Type | Required | Default | Description |
---|---|---|---|---|
x-api-key | String | O | - | API Key |
x-user-id | String | O | - | Issued user id |
timezone | String | X | UTC | Return the analysis results in the timezone specified by the header. For example, UTC, Asia/Seoul |
1.3 Query parameter
- "date_gte, date_lte, order_by" are based on the session_start_time.
Field | Type | Required | Default | Description |
---|---|---|---|---|
date_gte | String (YYYY-MM-DD ) | X | - | Return sessions that are greater than or equal to date_gte based on the timezone in the header |
date_lte | String (YYYY-MM-DD ) | X | - | Return sessions that are less than or equal to date_lte based on the timezone in the header |
order_by | String (ASC or DESC ) | X | DESC | DESC : Sort in descending orderASC : Sort in ascending order |
offset | Int | X | 0 | Number of sessions to skip |
limit | Int (Integer of 0~100 ) | X | 20 | Number of sessions to receive Max value is 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>"
2. Response
2.1 200 OK
- Successful session list retrieval
2.1.1 Body (result field)
Field | Type | Description |
---|---|---|
timezone | String | Timezone |
sleep_session_list | List of Sleep Session Objects | List of session data |
2.1.2 Sleep Session Object
if state == OPEN
: session_end_time is null
Field | Type | Description |
---|---|---|
session_id | String | Session ID |
state | String (OPEN ,CLOSED ,COMPLETE ) | Session stateOPEN : In-progress session, audio upload is possibleCLOSED : Session has been closed, audio file upload is not possible. Analysis of the uploaded sleep audio is ongoingCOMPLETE : Session has been closed and all sleep analysis is completed |
session_start_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm ) | Session start time Example) 2022-08-01T01:31:17+09:00 (for Asia/Seoul timezone in the request) |
session_end_time | String (YYYY-MM-DDThh:mm:ss+-hh:mm )? | Session end time Example) 2022-08-01T01:31:17+09:00 (for Asia/Seoul timezone in the request) |
created_timezone | String | Timezone of session creation (Timezone List) |
unexpected_end_time | String(YYYY-MM-DDThh:mm:ss+-hh:mm )? | If a session fails to proceed and terminate properly due to app crashes or similar issues, and the client later ends the session with an unexpected parameter set to 1, the time at which this happens is recorded. In this case, the "end_time" is calculated based on the sequence number of the last uploaded audio file. Therefore, if "end_time" is not null, it indicates an abnormal session. |
last_received_seq_num | Int? | Sequence number of the last uploaded audio file |
time_in_bed | Int (seconds )? | Time spent in bed |
2.2 400 Bad Request
- Invalid
timezone
is provided
{
"detail": "The invalid timezone is provided"
}
Updated about 1 year ago