Skip to content

matin/garth

Repository files navigation

Garth

CI codecov PyPI version PyPI - Downloads Documentation

Garmin SSO auth + Connect Python client

Features

  • OAuth1/OAuth2 authentication (OAuth1 token lasts ~1 year)
  • MFA support with custom handlers
  • Auto-refresh of OAuth2 token
  • Auto-resume from GARTH_HOME or GARTH_TOKEN environment variables
  • Works on Google Colab
  • Pydantic dataclasses for validated data
  • Built-in telemetry for diagnosing auth issues
  • Full test coverage

Installation

pip install garth

Quick Start

Authenticate and save session

import garth from getpass import getpass garth.login(input("Email: "), getpass("Password: ")) garth.save("~/.garth")

Resume session

import garth from garth.exc import GarthException garth.resume("~/.garth") try: garth.client.username except GarthException: # Session is expired. You'll need to log in again pass

Or use environment variables for automatic session restoration:

export GARTH_HOME=~/.garth # or export GARTH_TOKEN="eyJvYXV0aF90b2tlbi..." # from `uvx garth login`
import garth # Session is automatically loaded garth.client.username

Fetch data

# Get daily stress garth.DailyStress.list("2023-07-23", 7) # Get sleep data garth.SleepData.get("2023-07-20") # Get weight garth.WeightData.list("2025-06-01", 30) # Direct API calls garth.connectapi("/usersummary-service/stats/stress/weekly/2023-07-05/52")

Documentation

Full documentation at garth.readthedocs.io

MCP Server

garth-mcp-server is in early development.

To generate your GARTH_TOKEN, use uvx garth login.

Star History

Star History Chart