Skip to main content

Garmin SSO auth + Connect Python client (maintained fork of matin/garth)

Project description

garth-ng

PyPI version CI Python License: MIT

Garmin SSO auth + Connect Python client — maintained fork of matin/garth

About this fork

garth-ng is a maintained continuation of the original garth library by Matin Tamizi. The original project was deprecated after Garmin changed their auth flow. This fork restores compatibility and continues active development. The package name changed to garth-ng but the import stays import garth — same as Pillow keeping from PIL import Image.

Migrating from garth

Both packages install into the same site-packages/garth/ directory. You must uninstall the original first:

pip uninstall garth
pip install garth-ng

Your code stays unchanged. import garth works exactly as before.

Installation

pip install garth-ng
uv add garth-ng

The garth CLI requires typer — install the CLI extra:

pip install 'garth-ng[cli]'

Quick Start

Login and save session

import garth
from getpass import getpass

garth.configure(storage=garth.FileTokenStorage("~/.garth"))
garth.login(input("Email: "), getpass("Password: "))

MFA is handled automatically with a terminal prompt. Pass a custom handler if you need one:

garth.login(email, password, prompt_mfa=lambda: input("MFA code: "))

Resume a saved session

import garth

garth.configure(storage=garth.FileTokenStorage("~/.garth"))
print(garth.client.username)

Auto-load from environment

export GARTH_HOME=~/.garth
import garth

print(garth.client.username)  # loaded automatically

Or use a base64 token (useful in CI/containers):

export GARTH_TOKEN="eyJvYXV0aF90b2tlbi..."

Generate a token with the CLI:

garth login

For China region:

garth --domain garmin.cn login

Direct API calls

sleep = garth.connectapi(
    f"/wellness-service/wellness/dailySleepData/{garth.client.username}",
    params={"date": "2023-07-05", "nonSleepBufferMinutes": 60},
)

Stats and data

# Daily steps for the last 7 days
garth.DailySteps.list(period=7)

# Stress levels
garth.DailyStress.list("2023-07-23", 2)

# Weekly HRV
garth.DailyHRV.list(period=7)

# Sleep quality
garth.DailySleep.list(period=7)

Available stat types: DailySteps, WeeklySteps, DailyStress, WeeklyStress, DailyHRV, DailySleep, DailyHydration, DailyIntensityMinutes, WeeklyIntensityMinutes, DailyTrainingStatus, WeeklyTrainingStatus, MonthlyTrainingStatus

Available data types: SleepData, HRVData, WeightData, DailyHeartRate, BodyBatteryData, DailyBodyBatteryStress, DailySleepData, DailySummary, Activity, FitnessActivity, GarminScoresData, TrainingReadinessData, MorningTrainingReadinessData, BloodPressure, NutritionLog, NutritionSettings, NutritionStatus, PersonalRecord, PersonalRecordType, WeightGoal, StepsGoal

Activity includes sub-endpoint methods: details(), rounds(), exercise_sets(), hr_time_in_zones(), map_details(), workouts(), activity_types()

# Blood pressure
garth.BloodPressure.get("2024-01-15")
garth.BloodPressure.create(systolic=120, diastolic=80, pulse=72)

# Personal records
garth.PersonalRecord.list()
garth.PersonalRecord.for_activity(12345678901)

# Nutrition
garth.NutritionLog.get("2024-01-15")
garth.NutritionSettings.get()
garth.NutritionStatus.get()

# Goals
garth.WeightGoal.get()
garth.StepsGoal.get()

# Weight management
garth.WeightData.latest()
garth.WeightData.create(weight=75.5)

# Sleep logging
from datetime import datetime
garth.SleepData.create(
    sleep_start=datetime(2024, 1, 15, 23, 0),
    sleep_end=datetime(2024, 1, 16, 7, 0),
)

Upload an activity

with open("activity.fit", "rb") as f:
    garth.upload(f)

Configuration

garth.configure(domain="garmin.cn")        # China region
garth.configure(timeout=30)                # Request timeout (seconds)
garth.configure(retries=5, backoff_factor=1.0)  # Retry behavior
garth.configure(proxies={"https": "http://localhost:8888"}, ssl_verify=False)  # Proxy

License

MIT. Original library by Matin Tamizi. Fork maintained by CyberFossa.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

garth_ng-2.0.0a1.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

garth_ng-2.0.0a1-py3-none-any.whl (81.4 kB view details)

Uploaded Python 3

File details

Details for the file garth_ng-2.0.0a1.tar.gz.

File metadata

  • Download URL: garth_ng-2.0.0a1.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for garth_ng-2.0.0a1.tar.gz
Algorithm Hash digest
SHA256 15772296e35136b10ab3c5f744b13a725c4347ef349dd5e7a9f919a5aef7b754
MD5 1828844c071a4070e79ea39b101d6ecc
BLAKE2b-256 1c998734ab5d074f5713ba283085b7f2f5794e5af1a86ab99837caf4ce107b5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for garth_ng-2.0.0a1.tar.gz:

Publisher: release.yml on cyberfossa/garth-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file garth_ng-2.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: garth_ng-2.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 81.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for garth_ng-2.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba505f66d09e186f734edf7d3753c3f32c6c217858a0c0362608f4d87ccb795d
MD5 3d68783ccf3c02026818cfb20feeab42
BLAKE2b-256 861e205944b1b808582abdc4ec94bf30af38ba1db07d76eb7134c06641ce0797

See more details on using hashes here.

Provenance

The following attestation bundles were made for garth_ng-2.0.0a1-py3-none-any.whl:

Publisher: release.yml on cyberfossa/garth-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page