Sleep Measurements
Introduction
Sleep measurements capture such statistics as the length of time spent in various stages of sleep and the number of times awoken during the night for a user. Sleep measurements are grouped in reverse chronological order into a sleep feed.
This page describes an old representation. New applications should use the representation described here.Feed
Because they can grow very large, feeds are divided into pages (by default, each page contains 25 entries). Each page contains links to the previous and next pages as well as the total number of entries across all pages.
| Field | Type | Description |
|---|---|---|
size |
Integer |
The total number of entries across all pages |
items |
Item[] |
The entries in this page for the user, from newest to oldest |
previous |
String |
The URI of the previous page in the user's feed (omitted for the oldest page) |
next |
String |
The URI of the next page in the user's feed (omitted for the newest page) |
Past Entries
Past entries have the following structure:
| Field | Type | Description | Editable |
|---|---|---|---|
uri |
String |
The URI for this measurement set | N |
userID |
Integer |
The unique ID for the user | N |
timestamp |
String |
The timestamp (e.g., Sat, 1
Jan 2011 00:00:00)
|
N |
One of the following:
|
Double |
The value of the measured quantity | Y |
source |
String |
The name of the application that last modified this measurement | N |
previous |
String |
The URI of the previous measurement for the user (omitted for the oldest measurement) | N |
next |
String |
The URI of the next measurement for the user (omitted for the most-recent measurement) | N |
nearest_fitness_activity |
String |
The URI of the fitness activity closest in time to this activity for the user (omitted if no fitness activities have been recorded) | N |
nearest_teammate_fitness_activities |
String[] |
The URIs of the fitness activities closest in time to this activity for each friend (empty if no fitness activities have been recorded) | N |
nearest_strength_training_activity |
String |
The URI of the strength training activity closest in time to this activity for the user (omitted if no strength training activities have been recorded) | N |
nearest_teammate_strength_training_activities |
String[] |
The URIs of the strength training activities closest in time to this activity for each friend (empty if no strength training activities have been recorded) | N |
nearest_teammate_background_activities |
String[] |
The URIs of the background activities closest in time to this activity for each friend (empty if no background activities have been recorded) | N |
nearest_sleep |
String |
The URI of the sleep measurement closest in time to this activity for the user (omitted if no sleep measurements have been taken) | N |
nearest_teammate_sleep |
String[] |
The URIs of the sleep measurement closest in time to this activity for each friend (empty if no sleep measurements have been taken) | N |
nearest_nutrition |
String |
The URI of the nutrition measurement closest in time to this activity for the user (omitted if no nutrition measurements have been token) | N |
nearest_teammate_nutrition |
String[] |
The URIs of the nutrition measurement closest in time to this activity for each friend (empty if no nutrition measurements have been token) | N |
nearest_weight |
String |
The URI of the weight measurement closest in time to this activity for the user (omitted if no weight measurements have been token) | N |
nearest_teammate_weight |
String[] |
The URIs of the weight measurement closest in time to this activity for each friend (empty if no weight measurements have been token) | N |
nearest_general_measurement |
String |
The URI of the general measurement measurement closest in time to this activity for the user (omitted if no general measurements have been token) | N |
nearest_teammate_general_measurements |
String[] |
The URIs of the general measurement closest in time to this activity for each friend (empty if no general measurements have been token) | N |
nearest_diabetes |
String |
The URI of the diabetes measurement closest in time to this activity for the user (omitted if no diabetes measurements have been token) | N |
nearest_teammate_diabetes |
String[] |
The URIs of the diabetes measurement closest in time to this activity for each friend (empty if no diabetes measurements have been token) | N |
New Entries
New entries have the following structure:
| Field | Type | Description |
|---|---|---|
timestamp |
String |
The timestamp (e.g., Sat, 1
Jan 2011 00:00:00)
|
One of the following:
|
Double |
The value of the measured quantity |
post_to_twitter |
Boolean |
Whether to post this measurement to Twitter (optional; if omitted, the user's default setting will be used) |
post_to_facebook |
Boolean |
Whether to post this measurement to Facebook (optional; if omitted, the user's default setting will be used) |
Array Structures
items
| Field | Type | Description |
|---|---|---|
uri |
String |
The URI of detailed information for the measurement |
timestamp |
String |
The timestamp for the measurement (e.g., Sat,
1 Jan 2011 00:00:00)
|
One of the following:
|
Double |
The value of the measured quantity |
Measurement Quantities
| Field | Unit |
|---|---|
total_sleep |
min |
deep |
min |
rem |
min |
light |
min |
awake |
min |
times_woken |
|
|
Supported Operations
The following operations are supported on the URI of any page of a feed:
GET: Retrieves a page of the feedHEAD: Retrieves the HTTP headers for a page of the feedPOST: Adds an entry to the feed, if none exists for the given timestamp; otherwise, replaces the existing entry for the given timestamp
Note: For compatibility with existing clients, the response for a successful POST
is 201 Created, even if an existing entry is updated.
For GET requests, the following optional HTTP headers are supported:
If-Modified-Since: Indicates that the server should return a304 Not Modifiedresponse instead of the feed if it has not been modified since the given time
For GET requests, the following URI query parameters are supported:
noEarlierThan: Specifies the earliest time for which to return a sleep measurementnoLaterThan: Specifies the latest time for which to return a sleep measurementmodifiedNoEarlierThan: Specifies the earliest modification time for which to return a sleep measurementmodifiedNoLaterThan: Specifies the latest modification time for which to return a sleep measurement
The following operations are supported on the URI of any sleep measurement:
GET: Retrieves the sleep measurementHEAD: Retrieves the HTTP headers for the sleep measurementPUT: Updates the sleep measurementDELETE: Removes the sleep measurement
For GET requests, the following optional HTTP headers are supported:
If-Modified-Since: Indicates that the server should return a304 Not Modifiedresponse instead of the sleep measurement if it has not been modified since the given time
