Sleep
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.
Feed
Because a user’s sleep feed can grow very large, feeds are divided into pages of 25 activities at a time. Each page contains links to the previous and next pages as well as the total number of activities across all pages. Each page of a user's sleep feed has the following structure:
| Field | Type | Description |
|---|---|---|
size |
Integer |
The total number of sleep measurements across all pages |
items |
Item[] |
The user’s activities, 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 Measurements
Past sleep measurements have the following structure:
| Field | Type | Description | Editable |
|---|---|---|---|
uri |
String |
The URI for this measurement | N |
userID |
Integer |
The unique ID for the user | N |
timestamp |
String |
The time at which the measurement was taken (e.g., Sat, 1 Jan 2011 00:00:00) |
N |
One of the following values:
|
Double |
The value of the measured quantity | Y |
previous |
String |
The URI of the previous sleep measurement in chronological order for the user (omitted for the first sleep measurement) | N |
next |
String |
The URI of the next sleep measurement in chronological order for the user (omitted for the most recent sleep 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 street teammate (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 street teammate (empty if no strength training activities have been recorded) | N |
nearest_background_activity |
String |
The URI of the background activity closest in time to this activity for the user (omitted if no background activities have been recorded) | N |
nearest_teammate_background_activities |
String[] |
The URIs of the background activities closest in time to this activity for each street teammate (empty if no background activities have been recorded) | N |
nearest_teammate_sleep |
String[] |
The URIs of the sleep measurements closest in time to this activity for each street teammate (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 street teammate (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 measurements closest in time to this activity for each street teammate (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 measurements closest in time to this activity for each street teammate (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 measurements closest in time to this activity for each street teammate (empty if no diabetes measurements have been token) | N |
New Measurements
New mesaurements activities have the following structure:
| Field | Type | Description |
|---|---|---|
timestamp |
String |
The time at which the measurement was taken (e.g., Sat, 1 Jan 2011 00:00:00) |
One of the following values:
|
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 |
|---|---|---|
timestamp |
String |
The time at which the measurement was taken (e.g., Sat, 1 Jan 2011 00:00:00) |
One of the following values:
|
Double |
The value of the measured quantity |
uri |
String |
The URI of detailed information for the sleep measurement |
Supported Operations
Retrieving Measurement Information
To retrieve a user’s sleep feed or a sleep measurement,
GET
its URI.
Retrieving Headers for a Past Measurement
Header information for a past measurement can be retrieved with the
HEAD
method.
Editing a Past Measurement
To edit a past measurement,
PUT
any new values for editable fields to its URI.
Recording a New Measurement
To record a new measurement,
POST
its fields to any page in the user’s sleep feed.
Rate Limits
The following rate limits apply to activities and their feed on a per-user, per application basis:
- For
GETrequests: 5,000 requests in a 24-hour period - For
HEADrequests: 5,000 requests in a 24-hour period - For
POSTrequests: 5,000 requests in a 24-hour period - For
PUTrequests: 5,000 requests in a 24-hour period