Skip to main content

Python client for the WHOOP API with OAuth 2.0 support

Project description

whoop-api

Personal WHOOP data explorer using the WHOOP API.

Structure

whoop.py      # WhoopClient (OAuth2 + API) and WhoopAPI (token persistence)
main.py       # CLI entry point
main.ipynb    # Interactive data exploration

Auth Flow

sequenceDiagram
    participant U as User
    participant A as WhoopAPI
    participant W as WHOOP OAuth

    U->>A: WhoopAPI()
    A->>A: load token from disk
    alt no token / missing scopes
        A->>W: create_authorization_url()
        W-->>U: redirect URL
        U->>W: approve access
        W-->>U: redirect with code
        U->>A: paste redirect URL
        A->>W: fetch_token(code)
        W-->>A: access + refresh token
        A->>A: save token to disk
    else token expired
        A->>W: refresh_access_token()
        W-->>A: new token
        A->>A: save token to disk
    end
    A-->>U: authenticated WhoopClient

Data Flow

flowchart LR
    E[.env\nCLIENT_ID\nCLIENT_SECRET\nREDIRECT_URI] --> API[WhoopAPI]
    T[.whoop_token.json] <-->|load / save| API
    API --> C[WhoopClient]
    C -->|GET| S[/sleep]
    C -->|GET| R[/recovery]
    C -->|GET| W[/workout]
    C -->|GET| CY[/cycle]

Setup

pip install -r requirements.txt

.env

CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret
REDIRECT_URI=your_redirect_uri

Register your app at developer.whoop.com to get credentials.

Usage

Script

python main.py

Notebook

jupyter notebook main.ipynb

Library

from dotenv import load_dotenv
from whoop import WhoopAPI

load_dotenv()

with WhoopAPI() as api:
    sleep = api.get_sleep_collection(start_date="2026-06-01")
    recovery = api.get_recovery_collection()
    workouts = api.get_workout_collection()

The first run opens an interactive auth flow and saves the token to .whoop_token.json. Subsequent runs reuse or auto-refresh it.

API Reference

Method Description
get_profile() User profile
get_body_measurement() Height, weight, max HR
get_sleep_collection(start, end) All sleep records
get_sleep_by_id(id) Single sleep record
get_sleep_stream(id) Raw HR/temp signal stream
get_recovery_collection(start, end) All recovery scores
get_recovery_for_cycle(cycle_id) Recovery for a cycle
get_cycle_collection(start, end) All physiological cycles
get_cycle_by_id(id) Single cycle
get_workout_collection(start, end) All workouts
get_workout_by_id(id) Single workout

start / end are ISO date strings (e.g. "2026-06-01"). Defaults to the last 7 days.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whoop_py-0.1.0.tar.gz (53.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whoop_py-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file whoop_py-0.1.0.tar.gz.

File metadata

  • Download URL: whoop_py-0.1.0.tar.gz
  • Upload date:
  • Size: 53.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for whoop_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d6fc33a198d20b6bdea1999468e6be5989574ad1061b4d84abb11829cd3683b
MD5 6a477ef85b34e7869173022741975b96
BLAKE2b-256 774bb75b89c1dcc9e16f5355a902c6e6ab74aac9bdf9baa68c4d78d94079d2f7

See more details on using hashes here.

File details

Details for the file whoop_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: whoop_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for whoop_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7327400766c079f8f1dc4d3e78c6143b9729b5718122a6f8ec81a8a0ca8da35
MD5 050fcd096444cfda092eff37c5baaedd
BLAKE2b-256 9b6ca0113656e6dd9c2ecc82719c9a17c4901598b57a9989abf129f1b5337a6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page