Skip to content

Post sleep endpoints

pims edited this page Oct 14, 2014 · 5 revisions

/timeline/{day}

  • requires access token
  • scope: OAuthScope.SLEEP_TIMELINE
[
  {
    "score": 88,
    "message": "hello world",
    "date": "2014-09-08",
    "insights" : [
      {
        "condition": "ALERT",
        "message": "This reminds me of the time I was locked in the freezer at Dairy Queen.",
        "sensor": "temperature"
      },
      {
        "condition": "WARNING",
        "message": "Humidity was a little too high for ideal sleep conditions",
        "sensor": "humidity"
      }
    ],
    "segments": [
      {
        "id": 341348,
        "timestamp": 1410156300000,
        "duration": 60,
        "message": "something smart",
        "sensors": [],
        "sleep_depth": 100,
        "event_type": null,
        "offset_millis": -25200000
      },
      {
        "id": 341346,
        "timestamp": 1410156300000,
        "duration": 60,
        "message": "something smart",
        "sensors": [],
        "sleep_depth": 22,
        "event_type": "MOTION",
        "offset_millis": -25200000
      },
      
    ]
  }
]

Insights example:

{
    "condition": "ALERT",
    "message": "This reminds me of the time I was locked in the freezer at Dairy Queen.",
    "sensor": "temperature"
}

Possible values for condition : ALERT, IDEAL, WARNING, UNKNOWN

Possible values for sensor : temperature, humidity, particulates, sound, light

Raw call:

curl https://dev-api.hello.is/timeline/2014-09-08 -H'Authorization: Bearer 6.7af63c56571d43f5b7b20d712af94db1' -i
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 09 Sep 2014 20:22:27 GMT
transfer-encoding: chunked
Connection: keep-alive

[{"score":40, …]

/scores/sleep/{date}

  • requires access token
  • scope: OAuthScope.SLEEP_TIMELINE

Path variables:

  • days

/scores/sleep/{date}?days=n returns a sorted list of sleep scores (oldest date first).

Maximum days is capped at 5

Raw request:

curl -i 'https://dev-api.hello.is/v1/scores/sleep/2014-10-08?days=5' -H 'Authorization:Bearer 6.ced5eed27fbe44028548ba91ebbbffce'
HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 09 Oct 2014 23:31:34 GMT
Content-Length: 536
Connection: keep-alive

Return value:

[{"score":0,"date":"2014-10-04","version":"v_0_1","dateTimestamp":1412380800,"account_id":3,"type":"sleep"},
{"score":0,"date":"2014-10-05","version":"v_0_1","dateTimestamp":1412467200,"account_id":3,"type":"sleep"},
{"score":0,"date":"2014-10-06","version":"v_0_1","dateTimestamp":1412553600,"account_id":3,"type":"sleep"},
{"score":0,"date":"2014-10-07","version":"v_0_1","dateTimestamp":1412640000,"account_id":3,"type":"sleep"},
{"score":0,"date":"2014-10-08","version":"v_0_1","dateTimestamp":1412726400,"account_id":3,"type":"sleep"}
]
  • score is a number between 0 to 100. When score is 0, it means that we don't have pill data for that night.
  • date is for the night of sleep.
  • version is the current scoring algorithm version.
  • type indicates the type of score, currently, only "sleep" score is available.