GET child sleep - ocariot/api-gateway GitHub Wiki
Description
Retrieves a list with all sleep records associated with a Child.
Permissions:
-
Admin and Application users can list all Sleep objects of any Child.
-
A child can list all his sleep objects.
-
An Educator as well as a Health Professional can list all Sleep objects for any Child as long as the Child belongs to one of their groups.
-
A Family user can list all Sleep objects of any Child associated with them.
Scope
sleep:read
URL
Parameters
child_id: string (A 24-byte hex ID)
Curl example
curl -X GET "https://localhost/v1/children/5a62be07d6f33400146c9b61/sleep" -H "accept: application/json" -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response body
-
200
Successful requisition.[ { "id": "3bc1274329fb282470e45004", "start_time": "2019-08-18T01:40:30Z", "end_time": "2019-08-18T09:52:30Z", "duration": 29520000, "type": "classic", "pattern": { "data_set": [ { "start_time": "2019-08-18T01:40:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T01:41:30.00Z", "name": "asleep", "duration": 360000 }, { "start_time": "2019-08-18T01:47:30.00Z", "name": "restless", "duration": 240000 }, { "start_time": "2019-08-18T01:51:30.00Z", "name": "asleep", "duration": 60000 }, { "start_time": "2019-08-18T02:32:30.00Z", "name": "awake", "duration": 180000 }, { "start_time": "2019-08-18T06:47:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T06:48:30.00Z", "name": "asleep", "duration": 2580000 }, { "start_time": "2019-08-18T07:31:30.00Z", "name": "restless", "duration": 120000 }, { "start_time": "2019-08-18T09:36:30.00Z", "name": "asleep", "duration": 960000 } ], "summary": { "asleep": { "count": 4, "duration": 3960000 }, "awake": { "count": 1, "duration": 180000 }, "restless": { "count": 4, "duration": 480000 } } }, "child_id": "5a62be07de34500146d9c544" } ]
-
400
Validation errors -
403
Permission Error
Query Strings (Optional)
Query strings are used as follows: there must be a question mark following the URL and providing the parameters for the desired operations. There are four possible operations: filtering, paging, limiting, and sorting.
-
Filtering
https://localhost/v1/children/5a62be07d6f33400146c9b61/sleep?type=classic
-
Pagination
https://localhost/v1/children/5a62be07d6f33400146c9b61/sleep?page=1
-
Limitation
https://localhost/v1/children/5a62be07d6f33400146c9b61/sleep?limit=20
-
Sorting
https://localhost/v1/children/5a62be07d6f33400146c9b61/sleep?sort=type
All parameters can also be used together concatenated by the &
character as follows:
https://localhost/v1/children/5a62be07d6f33400146c9b61/sleep?type=classic&sort=type&page=1&limit=20
For more details about using Query Strings click here.