Skip to content

MixColumns/Whoop-API-Python-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WHOOP API Python Example

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.

🏃‍♂️ Overview

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.

alt text

🛠️ Tech Stack

  • 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

🚀 Quick Start

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/whoop-api-python-example.git
    cd whoop-api-python-example
  2. Install dependencies

    pip install fastapi httpx uvicorn
  3. 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"
  4. Run the application

    python script.py
  5. Open your browser Navigate to http://localhost:8000 to start the OAuth flow

📖 Usage

OAuth Flow

  1. Visit the home page at http://localhost:8000
  2. Click Login with WHOOP to start the OAuth process
  3. Authorize the application on the WHOOP website
  4. You will be redirected back with an access token

Data Dashboard

  1. Go to http://localhost:8000/data
  2. Enter your access token (manually)
  3. Click "Get Data" to retrieve some WHOOP data

🔌 API Endpoints

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

⚙️ Configuration

WHOOP Developer Setup

  1. Visit the WHOOP Developer Portal
  2. Create a new application
  3. Configure your redirect URI to match your application
  4. Copy your client ID and secret to the environment variables

🔗 Resources

⚠️ Disclaimer

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 🦊

About

Whoop API Python Example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages