Programmatic access to your Eight Sleep Pod. Sleep data, temperature control, alarms, base, speaker.
Eight Sleep has no API or data export. This CLI reverse-engineers the iOS app's endpoints so you can query your sleep data from the terminal or pipe it into scripts.
eight sleep last # last night's deep/REM/light, HR, HRV, score
eight sleep week --json # 7 days as JSON
eight temp set -40 # cool the bed
eight temp stage initial -50 # set autopilot deep sleep phaseIncludes CLAUDE.md and skills/ with research citations so Claude Code, Codex, or any coding agent can pull your sleep data and give evidence-based recommendations. Combine with blood work for the best results. The agent can trace causal chains that are invisible when looking at sleep or blood data in isolation (e.g. late bedtime compressing deep sleep, depleting DHEA-S, suppressing testosterone).
pip install -e .The Eight Sleep API doesn't have a public auth flow. You need to capture a bearer token from the iOS/Android app using a network proxy.
-
Install Proxyman on your iPhone: proxyman.io/ios
-
Set up HTTPS decryption:
- Open Proxyman on your iPhone
- Follow the in-app setup to install the Proxyman CA certificate
- Go to Settings > General > About > Certificate Trust Settings and enable trust for Proxyman CA
-
Capture the token:
- Start recording in Proxyman
- Open the Eight Sleep app and navigate around (pull down to refresh sleep data)
- In Proxyman, look for requests to
client-api.8slp.net - Tap any request and look at the request headers
- Copy the
Authorization: Bearer eyJ...value (everything after "Bearer ")
-
Get your user ID:
- In the same captured request, look at the URL path
- It will contain
/users/{userId}/- that's your user ID - Or decode the JWT token - the
subfield is your auth user ID
-
Save credentials:
eight auth --token "eyJ..." --user-id "your-user-id"
- Install Proxyman for Mac
- Enable iOS device proxying (Proxyman > Certificate > Install on iOS > Remote Device)
- Configure your iPhone's WiFi proxy to point at your Mac's IP on port 9090
- Install and trust the Proxyman CA certificate on your iPhone
- Open the Eight Sleep app and refresh
- Filter requests by
8slp.netin Proxyman - Right-click any request > Copy as cURL
- Extract the Bearer token and user ID from the curl command
If you have your Eight Sleep email and password:
eight auth --email you@email.com --password yourpasswordThis uses Eight Sleep's OAuth2 endpoint directly. The token expires after ~24 hours.
Eight Sleep beds have two sides. After auth, verify you're looking at the correct side:
eight whoami # shows your user ID and side (left/right)
eight device # shows leftUserId and rightUserIdIf you need the other side's data, re-auth with their user ID:
eight auth --token "same-token" --user-id "other-side-user-id"eight sleep last # last night's sleep
eight sleep today # current/most recent session
eight sleep week # last 7 days
eight sleep range 2024-01-01 2024-01-31 # custom range
# JSON output for piping/scripting
eight sleep last --json
eight sleep week --jsonSleep data includes: sleep score, deep/REM/light/awake durations, heart rate, HRV, respiratory rate, bed temperature, room temperature, toss & turns, presence start/end.
eight temp status # current temperature settings
eight temp set -30 # set level (-100 to 100)
eight temp set -50 -d 60 # set level for 60 minutes
eight temp on # turn on autopilot
eight temp off # turn off
# Set per-stage autopilot temperatures
eight temp stage bedtime -20
eight temp stage initial -40
eight temp stage final 10eight alarm list # list all alarms
eight alarm create 07:00:00 # create alarm at 7am
eight alarm enable ALARM_ID
eight alarm disable ALARM_ID
eight alarm snooze ALARM_ID --minutes 9
eight alarm dismiss ALARM_IDeight base status
eight base set --torso 20 --leg 10
eight base flateight speaker status
eight speaker tracks
eight speaker play
eight speaker pause
eight speaker volume 50
eight speaker track TRACK_IDeight whoami # authenticated user info
eight device # device details (model, firmware, sides)
eight away start # start away mode
eight away end # end away mode
eight prime # start priming cycleAll commands support --json for structured output:
eight sleep week --json | jq '.days[] | {day, score, deepDuration}'Three base URLs:
- Auth:
https://auth-api.8slp.net/v1 - Client API:
https://client-api.8slp.net/v1 - App API:
https://app-api.8slp.net/
| Endpoint | Method | Description |
|---|---|---|
/v1/tokens (auth) |
POST | OAuth2 password grant |
/v1/users/me |
GET | Authenticated user info |
/v1/devices/{id} |
GET | Device info (sides, features) |
/v1/users/{id}/trends |
GET | Sleep data (the main endpoint) |
/v1/users/{id}/temperature (app) |
GET/PUT | Temperature control |
/v2/users/{id}/alarms (app) |
GET | List alarms |
/v1/users/{id}/alarms (app) |
POST | Create alarm |
/v1/users/{id}/base (app) |
GET | Base status |
/v1/users/{id}/audio/player (app) |
GET | Speaker status |
tz=America/Los_Angeles
from=2024-01-01
to=2024-01-07
include-all-sessions=true
include-main=false
model-version=v2
score # sleep score (0-100)
sleepDuration # total sleep seconds
deepDuration / remDuration / lightDuration # stage durations
presenceStart / presenceEnd # bed entry/exit (UTC)
tnt # toss & turns count
sleepQualityScore.heartRate.average # avg HR during sleep
sleepQualityScore.hrv.current # HRV
sleepQualityScore.respiratoryRate.average # breath rate
sleepQualityScore.tempBedC.average # bed temperature
sleepQualityScore.tempRoomC.average # room temperature
sessions[].stages[] # sleep stage timeline
sessions[].timeseries.heartRate # HR time series [[ts, val], ...]
| Variable | Description |
|---|---|
EIGHT_SLEEP_TOKEN |
Bearer token from auth |
EIGHT_SLEEP_USER_ID |
Your user ID |
EIGHT_SLEEP_DEVICE_ID |
Device ID (auto-detected) |
Stored in .env in the CLI directory or parent directory.
Clone this repo, install the CLI, authenticate, and point your agent at it. The CLAUDE.md and skills/ directory give the agent everything it needs.
git clone https://github.com/bhaktatejas922/eightsleep-cli.git
cd eightsleep-cli
pip install -e .
eight auth --email you@email.com --password yourpassThen in Claude Code (or any agent that reads CLAUDE.md):
> analyze my sleep this week and tell me what to change
> correlate my Eight Sleep data with this blood panel [paste results]
> what temperature settings should I use for more deep sleep?
> build me a health dashboard combining sleep and blood work
The agent will use the CLI to pull your data, reference the skill files for research context, and give you evidence-based recommendations.
For the best analysis, save your blood panel results as a markdown file in the repo:
bloodresults/
2024-01-15-quest.md
2024-06-01-labcorp.md
The agent can then correlate sleep patterns with blood markers: how your bedtime timing affects testosterone, how deep sleep duration relates to fasting glucose, whether your HRV trends predict cortisol levels.
| File | What It Covers |
|---|---|
skills/sleep-optimization.md |
Deep sleep science, metric targets, bedtime timing research, temperature protocols |
skills/temperature-protocol.md |
Eight Sleep temperature settings for different goals, troubleshooting, cited papers |
skills/blood-sleep-connections.md |
How sleep metrics map to blood markers (testosterone, glucose, cortisol, DHEA-S, vitamin D, WBC) |
API structure derived from lukas-clarke/eight_sleep (Home Assistant integration).