Welcome
Welcome to the Sleepme public developer API! Below are a few steps for you to get started with working with our platform.
What this API can do
The Sleepme API allows you to list, retrieve details, and to update the state of your claimed Sleepme devices. This allows for rich third-party integrations and can help enhance your experience with our product line.
Generating a token
The first step to accessing the API is to generate a developer token. This can be done by performing the following steps:
Log in to Sleep.me
Log in to your Sleepme account at
Access the developers section
Under the account screen, go to Developer Portal
.
Generate a token
Generate an access token under the Personal access tokens
section. You may give the token a friendly name to help you identify it later.
NOTE: You can only create a token once you have a claimed device on your account.
Your new token will then be displayed:
NOTE: Make sure you copy the token down somewhere before dismissing this window. You won’t be able to see the full token after this window is dismissed.
Deleting a token
Tokens may be deleted by pressing the delete button next to them.
Restrictions
At this time, a single Sleepme user can generate up to 10 developer tokens. This may change in the near future. Tokens do not expire at this time, but may be revoked as necessary.
Making a request
Get a list of claimed devices
curl --location --request GET 'https://api.developer.sleep.me/v1/devices' \
--header 'Authorization: Bearer ACCESS_TOKEN_HERE' \
--header 'Content-Type: application/json'
Response:
[
{
"id": "zx-cagh25ahjfawkfawhg",
"name": "My Dock Pro",
"attachments": [
"CHILIPAD_PRO"
]
},
{
"id": "zx-wagagj21qk222j25525",
"name": "Another Dock Pro",
"attachments": [
"CHILIPAD_PRO"
]
}
]
A 200 - OK response indicates success.
Get a single device
curl --location --request GET 'https://api.developer.sleep.me/v1/devices/<DEVICE_ID>' \
--header 'Authorization: Bearer ACCESS_TOKEN_HERE' \
--header 'Content-Type: application/json'
Response:
{
"about": {
"firmware_version": "5.15",
"ip_address": "25.26.873.23",
"lan_address": "192.168.0.131",
"mac_address": "b5:56:12:67:jg:w2",
"model": "DP999NA",
"serial_number": "6236265923682376276"
},
"control": {
"brightness_level": 100,
"display_temperature_unit": "f",
"set_temperature_c": 23.5,
"set_temperature_f": 74,
"thermal_control_status": "active",
"time_zone": "America/New_York"
},
"status": {
"is_connected": true,
"is_water_low": false,
"water_level": 100,
"water_temperature_f": 74,
"water_temperature_c": 23.5
}
}
Update a device’s status
curl --location --request PATCH 'https://api.developer.sleep.me/v1/devices/<DEVICE_ID>' \
--header 'Authorization: Bearer ACCESS_TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data-raw '{
"set_temperature_f": 95
}'
A 200 - OK response indicates success.
Rate Limiting
To ensure the stability of our system we have implemented rate limiting on all Sleepme public developer APIs.
We limit the number of requests that can be processed, per user account, to 10 requests per discrete minute window.
A basic technique for calling systems to gracefully handle limiting is to watch for the 429 status code and build in a retry mechanism. The retry mechanism should follow an exponential backoff schedule to reduce request volume when necessary.
Closing Notes
If you have successfully completed the above steps, congratulations! You are now integrated with the Sleep.me Developer API. We can’t wait to see what you do with these tools.
From here, we suggest reading through the API specification for a full understanding of the available API endpoints and their parameters.
For any help or assistance, please reach out to developers@sleep.me.