This code can be used to extract all workouts using the Whoop API.
Credits: The whoop.py file with the Whoop API Client implementation was simply copied from https://github.com/hedgertronic/whoop/.
Number of workouts in 2023: 279
Total kcal: 100562.94 kcal
Average kcal: 360.44 kcal
Total duration: 169h 42m 2s (7 days, 1:42:02)
Average duration: 0:36:29
Top 3 activities:
Running: 164
Functional Fitness: 58
Yoga: 42pip install -r requirements.txtThe only dependencies listed in there are Authlib and requests.
Set the following variables in get_workouts.py:
username: Your Whoop email/usernamepassword: Your Whoop passwordstart_date: The day until it should collect the workouts
Then run
python get_workouts.pyThis will collect the workouts from today until the specified start date and dumps it to a file called workouts.json.
Run
python analyze_workouts.pyThis loads the JSON file and prints the stats for 2023.
Note: The current logic filters for 2023 workouts and ignores activities categorized as Unknown, MISC, and Walking. If you want to modify this logic, change the code in the filter_workouts() function.
Whoop specifies a sport_id for each workout. I compared these numbers with my workouts to identify the corresponding activity.
So far I've converted the following sport_id values to workout names:
SPORT_ID_TO_NAME = {
0: "Running",
1: "Bicycle",
33: "Swimming",
96: "HIIT",
71: "MISC",
43: "Pilates",
44: "Yoga",
48: "Functional Fitness",
52: "Hiking",
-1: "Unknown Activity",
63: "Walking",
}