问题
When I hit the sleeps endpoint, I don't see any value returned for deep sleep.
I sent this request: https://jawbone.com/nudge/api/v.1.1/users/@me/sleeps?date=20160525
And this is the response I received:
{u'data': {u'items': [{u'date': 20160525,
u'details': {u'asleep_time': 1464152838,
u'awake': 2284,
u'awake_time': 1464183066,
u'awakenings': 1,
u'body': u'',
u'duration': 30828,
u'light': 14661,
u'mind': 0,
u'quality': u'',
u'rem': 11265,
u'smart_alarm_fire': u'',
u'sound': 2618,
u'sunrise': None,
u'sunset': None,
u'tz': u'America/Los_Angeles'},
u'shared': True,
u'sub_type': 0,
u'time_completed': 1464183066,
u'time_created': 1464152238,
u'time_updated': 1464189792,
u'title': u'for 7h 55m',
u'xid': u'<XID>'}],
u'size': 1},
u'meta': {u'code': 200,
u'message': u'OK',
u'time': 1464219784,
u'user_xid': u'<XID>'}}
Where is the value for deep sleep?
Additionally, when I make a request for the ticks for this sleep: https://jawbone.com/nudge/api/v.1.1/sleeps//ticks
I get this response:
{u'data': {u'items': [{u'depth': 1, u'time': 1464152238},
{u'depth': 2, u'time': 1464152838},
{u'depth': 3, u'time': 1464155641},
{u'depth': 3, u'time': 1464156465},
{u'depth': 3, u'time': 1464157134},
{u'depth': 3, u'time': 1464158170},
{u'depth': 3, u'time': 1464159358},
{u'depth': 3, u'time': 1464160060},
{u'depth': 2, u'time': 1464160821},
{u'depth': 3, u'time': 1464161157},
{u'depth': 1, u'time': 1464161492},
{u'depth': 2, u'time': 1464162532},
{u'depth': 3, u'time': 1464162930},
{u'depth': 2, u'time': 1464163656},
{u'depth': 3, u'time': 1464164715},
{u'depth': 2, u'time': 1464165502},
{u'depth': 3, u'time': 1464168230},
{u'depth': 2, u'time': 1464169924},
{u'depth': 3, u'time': 1464170771},
{u'depth': 2, u'time': 1464171134},
{u'depth': 3, u'time': 1464171739},
{u'depth': 2, u'time': 1464172253},
{u'depth': 3, u'time': 1464174025},
{u'depth': 2, u'time': 1464175249},
{u'depth': 3, u'time': 1464176444},
{u'depth': 2, u'time': 1464178035},
{u'depth': 3, u'time': 1464179690},
{u'depth': 1, u'time': 1464181159},
{u'depth': 2, u'time': 1464181803}],
u'size': 29},
u'meta': {u'code': 200,
u'message': u'OK',
u'time': 1464220564,
u'user_xid': u'105utfm8iq4'}}
According to the documentation, 1=awake, 2=light, 3=deep, so where is REM?
回答1:
There are two issues here.
The first is that the sleeps endpoint documentation is out of date. In the response from the sleeps endpoint, use the 'sound' value for the total deep sleep. In the response above, this would be:
u'sound': 2618,
The second issue is that the sleep ticks do not currently distinguish between deep/sound sleep and REM.
We will review these issues internally and update the documentation and the behavior of the API.
来源:https://stackoverflow.com/questions/37449842/how-can-i-get-deep-and-rem-sleep-data-from-the-jawbone-up-api