从Garmin Connect获取健康与健身数据——40+项指标,包括睡眠、HRV、压力、身体电量、血氧、VO2 Max、训练状态和活动。
Fetch comprehensive health & fitness data from Garmin Connect for your AI agent.
CategoryFieldsActivitySteps, distance, calories (active + BMR), floors, intensity minutesHeart RateMin/max/resting heart rateSleepDuration, score, deep/light/REM/awake breakdown, stress during sleepHRVLast night avg, 5min peak, weekly avg, status (balanced/unbalanced), baselineBody BatteryCurrent level, daily min/maxSpO2Average and minimum blood oxygenRespirationWaking and sleep breathing rateStressAverage/max, rest/low/medium/high duration breakdownTraining StatusOverreaching/Highly Active/Productive/Maintaining/Recovery/Detraining + acute/chronic load ratioTraining ReadinessScore (0-100)Fitness MetricsVO2 Max, fitness age, endurance score, hill scoreRace Predictions5K/10K/Half/Marathon predicted timesWeight/Body CompWeight (kg), body fat %, BMI (requires Garmin Index scale)HydrationIntake (ml) vs goalActivitiesIndividual workouts with HR, duration, calories, elevation, training effect, and detail JSONWeekly SummaryTotal/avg steps for the weekSQLite Tablesdaily_summary, activities, and activity_sets for queryable local analysis
bash
pip install "garminconnect>=0.3.11"
Option A -- Environment variables:
bash
export GARMIN_EMAIL="you@example.com"
export GARMIN_PASSWORD="yourpassword"
Option B -- CLI args:
bash
python3 garmin_health.py --email you@example.com --password yourpassword
Option C -- macOS Keychain:
bash
security add-generic-password -a "you@example.com" -s "garmin_connect" -w "yourpassword"
Option D -- Credentials file:
bash
echo -e "email=you@example.com\npassword=yourpassword" > ~/.garmin_credentials
chmod 600 ~/.garmin_credentials
If your Garmin account was registered in China, add this to your shell profile ( ~/.zshrc / ~/.bashrc) once:
bash
export GARMIN_IS_CN=true
This tells the skill to use connect.garmin.com.cn instead of the global endpoint -- more reliable for mainland China IPs and prevents 429 rate-limit errors. Skip this step if you have a global Garmin account.
First login may require MFA verification. You'll be prompted to enter a code sent to your email.
garminconnect 0.3.x uses native authentication and cannot reuse legacy Garth token files. Upgrading from 0.2.x requires one new interactive login and MFA challenge.
Ask your AI agent:
bash
# Fetch today's data (default)
python3 garmin_health.py
# Fetch specific date
python3 garmin_health.py --date 2026-03-16
# Show latest cached data
python3 garmin_health.py --show
# Use Garmin Connect CN endpoint (Chinese accounts / mainland China IP)
python3 garmin_health.py --cn
# With credentials
python3 garmin_health.py --email you@example.com --password pass
~/.garmin_health/YYYY-MM-DD.json -- Daily JSON snapshots~/.garmin_health/latest.json -- Most recent JSON snapshot~/.garmin_health/garmin.db -- SQLite database with daily_summary, activities, and activity_sets tables~/.garminconnect/ -- OAuth token cacheOverride with env vars:
GARMIN_DATA_DIR -- Change data directoryGARMIN_TOKENSTORE -- Change token cache directoryGARMIN_IS_CN=true -- Use Garmin Connect CN endpoint (set once in shell profile)All labels and output in English. JSON field names are English by design.
~/.garminconnect/). Subsequent runs reuse this token and do not re-send your password.--password CLI flag to avoid password exposure in shell history.connect.garmin.com (or connect.garmin.com.cn for CN accounts). No proxies or intermediaries.garminconnect >= 0.3.11