A comprehensive Python FastAPI application demonstrating OAuth integration with the WHOOP API for accessing fitness and health data.
More endpoints for further data retrieval can be found at https://developer.whoop.com/api.
This project provides a complete example of how to integrate with the WHOOP API using Python and FastAPI. It demonstrates the OAuth 2.0 authorization code flow (without refresh tokens) and shows how to retrieve user profiles and physiological cycles.
- FastAPI: Modern, fast web framework for building APIs
- HTTPX: Async HTTP client for API requests
- Uvicorn: ASGI server for running the application
- Python 3.7+: Modern Python with async/await support
-
Clone the repository
git clone https://github.com/yourusername/whoop-api-python-example.git cd whoop-api-python-example -
Install dependencies
pip install fastapi httpx uvicorn
-
Set up environment variables You can the values in the developer Dashboard.
export WHOOP_CLIENT_ID="your_client_id" export WHOOP_CLIENT_SECRET="your_client_secret" export WHOOP_REDIRECT_URI="http://localhost:8000/callback"
-
Run the application
python script.py
-
Open your browser Navigate to
http://localhost:8000to start the OAuth flow
- Visit the home page at
http://localhost:8000 - Click
Login with WHOOPto start the OAuth process - Authorize the application on the WHOOP website
- You will be redirected back with an access token
- Go to
http://localhost:8000/data - Enter your access token (manually)
- Click "Get Data" to retrieve some WHOOP data
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Home page with login link |
/login |
GET | Initiates OAuth flow |
/callback |
GET | OAuth callback endpoint |
/data |
GET | Data dashboard form |
/data |
POST | Retrieve and display WHOOP data |
/favicon.ico |
GET | Serve favicon |
- Visit the WHOOP Developer Portal
- Create a new application
- Configure your redirect URI to match your application
- Copy your client ID and secret to the environment variables
This is an unofficial example application and is not affiliated with WHOOP, Inc. Use this code at your own risk and ensure compliance with WHOOPs API terms of service.
Made by a 🦊
