API Examples

API Examples

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.