Python client for Garmin Connect API
Actively maintained. Last release 3 days ago, commits in 20 of the last 26 weeks. A safe choice.
pip install ha-garminha-garmin
Python client for Garmin Connect API, designed for Home Assistant integration.
Note: ha-garmin covers the subset of the Garmin Connect API that the Home Assistant Garmin Connect integration needs, with data shaped for its coordinators and sensors. For the full suite of Garmin Connect API calls, use python-garminconnect.
Features
- Native Garmin Connect API integration
- Fully async - aiohttp for the data API (session can be injected), curl_cffi
AsyncSessionfor login, MFA and token refresh - Robust authentication with multiple login strategies and automatic fallbacks
- MFA support with automatic endpoint fallback
- Token persistence - save and restore sessions to avoid re-login
- Automatic token refresh - proactively refreshes before expiry
- Retry with backoff for rate limits (429) and server errors (5xx)
- Midnight fallback - automatically uses yesterday's data when today isn't ready yet
- Coordinator-based fetch - optimized data fetching for Home Assistant multi-coordinator pattern
- Data transformations - automatic unit conversions (seconds→minutes, grams→kg)
Installation
pip install ha-garmin
Optional: install with improved browser UA generation:
pip install ha-garmin[ua]
Usage
ha-garmin is fully async: every network call is awaited on the event loop.
- Data API: aiohttp. Pass your own
aiohttp.ClientSession(Home Assistant passes its own); without one the client creates a session, which you release withawait client.close()orasync with. - Login, MFA and token refresh:
curl_cffi's asyncioAsyncSessionwith TLS impersonation. Garmin's web application firewall only lets browser- or app-like TLS fingerprints through to SSO, which aiohttp cannot produce, so these keep their own short-lived sessions. That also keeps SSO cookies out of a shared cookie jar.