A Python library for extracting health and fitness data from Garmin Connect, designed for integration with OpenClaw and other health insight applications.
- Comprehensive Data Extraction: Access activities, sleep, heart rate, stress, steps, body composition, hydration, and more
- Easy Authentication: OAuth-based authentication with token persistence
- OpenClaw Integration Ready: Designed for seamless integration with AI health assistants
- CLI Tool: Command-line interface for quick data access
- Type-Safe Models: Pydantic-based data models with full type hints
- Flexible Export: Export data in JSON format for analysis
# Install from source
pip install -e .
# Or with development dependencies
pip install -e ".[dev]"# Login to Garmin Connect
garmer login
# Check authentication status
garmer status
# Get today's summary
garmer summary
# Get sleep data
garmer sleep
# Get recent activities
garmer activities
# Get full health snapshot
garmer snapshot --json
# Export data
garmer export --days 7 -o my_data.jsonfrom garmer import GarminClient
# Login with credentials (tokens are saved automatically)
client = GarminClient.from_credentials(
email="your-email@example.com",
password="your-password",
)
# Or use saved tokens
client = GarminClient.from_saved_tokens()
# Get today's summary
summary = client.get_daily_summary()
print(f"Steps: {summary.total_steps}")
# Get sleep data
sleep = client.get_sleep()
print(f"Sleep: {sleep.total_sleep_hours:.1f} hours")
# Get recent activities
activities = client.get_recent_activities(limit=5)
for activity in activities:
print(f"{activity.activity_name}: {activity.distance_km:.1f} km")
# Get comprehensive health snapshot
snapshot = client.get_health_snapshot()
# Get weekly report
report = client.get_weekly_health_report()- Running, cycling, swimming, and 20+ activity types
- Duration, distance, pace, heart rate zones
- Laps, splits, GPS data (via detailed endpoints)
- Training effect metrics
- Total sleep duration and phases (deep, light, REM)
- Sleep score and quality metrics
- Heart rate, HRV, respiration during sleep
- Sleep phases timeline
- Resting heart rate
- Heart rate samples throughout the day
- Heart rate zones
- 7-day averages
- Overall stress level
- Stress samples throughout the day
- Rest vs. stress duration
- Body Battery correlation
- Total steps and goal tracking
- Distance traveled
- Floors climbed
- Intensity minutes (moderate/vigorous)
- Sedentary time
- Weight tracking
- Body fat percentage
- Muscle mass, bone mass
- BMI, metabolic age
- Water intake tracking
- Daily goals
- Sweat loss correlation
- Breathing rate (waking and sleeping)
- Respiratory trends
Garmer is designed to work seamlessly with OpenClaw for health insights:
from garmer.examples.openclaw_integration import GarminIntegration
integration = GarminIntegration()
# Get health summary for AI analysis
summary = integration.get_health_summary()
# Returns structured data with metrics and insights
# Get activity analysis
activities = integration.get_activity_insights(days=7)
# Get sleep trend analysis
sleep_trends = integration.get_sleep_trends(days=7)
# Generate daily briefing
briefing = integration.get_daily_briefing()Garmer stores configuration and tokens in ~/.garmer/:
~/.garmer/
├── garmin_tokens # OAuth tokens (auto-created after login)
├── config.json # Optional configuration file
└── exports/ # Default export directory
GARMER_TOKEN_DIR: Directory for token storageGARMER_LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)GARMER_CACHE_ENABLED: Enable/disable caching (true/false)
All data is returned as Pydantic models with type hints:
from garmer.models import (
Activity,
SleepData,
HeartRateData,
StressData,
StepsData,
DailySummary,
UserProfile,
)
# Models can be converted to dictionaries
activity_dict = activity.to_dict()
# Or accessed with full type support
print(activity.distance_km) # float
print(activity.avg_heart_rate) # int | Nonefrom garmer.auth import AuthenticationError, SessionExpiredError
try:
client = GarminClient.from_saved_tokens()
except AuthenticationError:
print("Please login first: garmer login")
try:
data = client.get_daily_summary()
except SessionExpiredError:
# Token expired, need to re-authenticate
client.login(email, password)# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src/garmer
# Linting
ruff check src/garmerMIT License
- Uses the garth library for Garmin Connect authentication
- Inspired by the need for comprehensive health data integration with AI assistants