garminconnect is a Python 3 API wrapper for Garmin Connect, enabling programmatic access to a user's health metrics, activity data, workouts, and other fitness information. The library is actively maintained, with frequent updates (current version 0.3.2) to adapt to changes in Garmin's API infrastructure, particularly authentication and Cloudflare bypass mechanisms.
pip install garminconnect curl_cffi ua-generatorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to log in to Garmin Connect and retrieve activity data for the current day. It emphasizes using environment variables for sensitive credentials. The library handles token saving and refreshing automatically after the initial login. Make sure to set `GARMIN_USERNAME` and `GARMIN_PASSWORD` in your environment.
Saved tokens from versions prior to 0.3.0 are incompatible. A fresh login (`api.login()`) is required after upgrading. Additionally, install the new mandatory dependencies: `curl_cffi` and `ua-generator`.
The library (v0.3.0+) implements TLS impersonation strategies and random browser fingerprinting (via `curl_cffi` and `ua-generator`) to mitigate Cloudflare blocking. Ensure these dependencies are installed. If issues persist, reduce API call frequency or try initiating login from a different network/IP. Persistent blocks might require contacting Garmin support.
For interactive use, the `login()` method will prompt for an MFA code if required. For automated scripts, you can provide the MFA code using the `GARMIN_MFA_CODE` environment variable for the `prompt_mfa` callback, or implement a custom `prompt_mfa` handler in the `Garmin` constructor.