Garmin Daily Report: Step 2 – Python Script & Garmin Connect API

Overview

Python project that connects to the Garmin Connect API using the garminconnect package (v0.2.36) and the garth OAuth library to fetch health, fitness, and activity data. The daily_report.py script generates a comprehensive daily health report.

GitHub: garminconnector


Prerequisites

  • Python 3.10+
  • A Garmin Connect account with a compatible Garmin device
  • PDM (Python package manager) — optional, for local development

Project Structure

GarminConnector/
├── garminconnect/           # Core library (API wrapper)
│   ├── __init__.py          # Main Garmin class with 100+ API methods
│   ├── fit.py               # FIT file encoder
│   └── workout.py           # Workout data structures
├── custom_scripts/          # Data fetching & reporting scripts
│   ├── daily_report.py      # Daily health & activity report
│   ├── weekly_report.py     # Weekly aggregate report
│   ├── trainer_report.py    # Advanced trainer metrics
│   ├── training_readiness.py
│   └── ...more scripts
├── config.py                # Garmin credentials (NOT in git)
├── config.example.py        # Credential template
├── Dockerfile               # Docker containerization
├── docker-compose.yml       # Docker service definition
└── pyproject.toml           # PDM config & dependencies

Step 1: Clone the Repository

git clone https://github.com/strider73/garminconnector.git
cd garminconnector

Step 2: Set Up Credentials

Copy the example config and fill in your Garmin Connect login:

cp config.example.py config.py
nano config.py
# config.py
email = "your_garmin_email@example.com"
password = "your_garmin_password"

# Heart rate intensity thresholds (bpm)
MODERATE_MIN = 110
MODERATE_MAX = 120
VIGOROUS_MIN = 120

Warning: config.py contains credentials and is in .gitignore. Never commit it to a public repo.


Step 3: Install Dependencies (Local Development)

Using PDM:

pdm install
pdm run report

Or directly with pip:

pip install "garth>=0.5.17,<0.6.0"
python3 custom_scripts/daily_report.py

What the Daily Report Outputs

The daily_report.py script generates a formatted report with these sections:

Section Data
Sleep Analysis Duration, stages (deep/light/REM), sleep scores, 7-day comparison
Activity & Fitness Steps, distance, calories (total/active/BMR), intensity minutes, floors
Heart Rate Resting, max, min HR with 7-day comparison
Stress & Recovery Average/max stress, body battery
Workouts Today’s activities with type, duration, distance, pace, calories, HR

Each section includes 7-day comparisons showing arrows (↗ better, ↘ worse) against the best performance from the past week.


Authentication Flow

The script uses the garth library for OAuth authentication:

  1. First run: Logs in with email/password, saves tokens to ~/.garth
  2. Subsequent runs: Resumes session from cached tokens
  3. Token expiry: Automatically re-authenticates with credentials

Available Scripts

pdm run report        # Daily health snapshot
pdm run weekly        # Weekly aggregate report
pdm run trainer       # Advanced trainer metrics
pdm run readiness     # Training readiness assessment
pdm run health        # Health-focused weekly summary
pdm run heart-rate    # HR metrics analysis
pdm run today         # Quick today snapshot
pdm run workouts      # Workout list
pdm run full-report   # Generate everything

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top