github cyberjunky/python-garminconnect v0.3.4

7 hours ago

What's Changed

Features

  • Typed response layer (g.typed accessor) — an optional Pydantic namespace that wraps high-value read endpoints with validated, IDE-friendly models. Requires pydantic>=2.0; zero impact on existing users.

    pip install garminconnect[typed]
    g = Garmin(email, password)
    raw   = g.get_stats(date)         # dict[str, Any] — unchanged
    stats = g.typed.get_stats(date)   # DailyStats (Pydantic model)
    print(stats.total_steps, stats.resting_heart_rate)

    Supported methods in this release:

    Method Typed return
    get_stats, get_user_summary DailyStats
    get_sleep_data SleepData
    get_hrv_data HrvData | None
    get_body_battery list[BodyBatteryEntry]
    get_training_readiness list[TrainingReadiness]
    get_activities_by_date list[Activity]

    Validation failures raise GarminConnectResponseValidationError with .raw preserved. Extra/missing fields are tolerated so schema drift doesn't break running apps. Marked experimental — the surface may evolve based on feedback.

Bug Fixes

  • CN account token refresh — DI OAuth2 token endpoint now routes to diauth.garmin.cn for is_cn=True accounts. Previously the .com endpoint was always used, causing refresh failures (invalid_grant) after the ~4-hour access token TTL expired. Cron-driven sync jobs and long-running sessions on CN accounts are now fixed. (PR #360 by @MidnightV1)

Contributors

Full Changelog: v0.3.3...v0.3.4

Don't miss a new python-garminconnect release

NewReleases is sending notifications on new releases.