What are Providers?
Providers are plugin modules that integrate Mirobody Health with external health and fitness device APIs. Each provider handles OAuth authentication, data fetching, and transformation into a standardized format.
Provider Architecture
Mirobody Health uses an extensible provider architecture that makes it easy to add new health device integrations:Core Components
Authentication Handler
Manages OAuth 1.0 or OAuth 2.0 flows for secure user authorization
Data Puller
Fetches health data from vendor APIs with pagination and rate limiting
Data Formatter
Transforms vendor-specific data into standardized health indicators
Database Service
Persists both raw and formatted data for audit trails
Available Providers
Garmin Connect
- Overview
- Supported Data
- Configuration
Authentication: OAuth 1.0
Status: Production Ready
Data Types: Activities, Sleep, Heart Rate, HRV, Respiration, Stress, Body CompositionGarmin Connect is one of the most comprehensive health data sources, providing detailed metrics from Garmin wearables and fitness devices.
Status: Production Ready
Data Types: Activities, Sleep, Heart Rate, HRV, Respiration, Stress, Body CompositionGarmin Connect is one of the most comprehensive health data sources, providing detailed metrics from Garmin wearables and fitness devices.
Whoop
- Overview
- Supported Data
- Configuration
Authentication: OAuth 2.0
Status: Production Ready
Data Types: Sleep, Recovery, Cycles, Workouts, Body MeasurementsWhoop provides comprehensive recovery and strain metrics popular with athletes and fitness enthusiasts.
Status: Production Ready
Data Types: Sleep, Recovery, Cycles, Workouts, Body MeasurementsWhoop provides comprehensive recovery and strain metrics popular with athletes and fitness enthusiasts.
Provider Lifecycle
Understanding the provider lifecycle helps you work with providers effectively:1
Initialization
Providers are automatically discovered and initialized on application startup from directories specified in
THETA_PROVIDER_DIRS.config.yaml
2
Registration
Each provider’s
create_provider() class method is called to validate configuration and create an instance.3
User Linking
When a user initiates linking, the provider’s
link() method generates an OAuth URL.4
Authentication
After user authorization, the provider’s
callback() method exchanges tokens and saves credentials.5
Data Synchronization
Periodically or on-demand, the provider pulls data from the vendor API, saves raw data, formats it, and pushes to the platform.
6
Unlinking
When a user unlinks, the provider’s
unlink() method revokes access and removes stored credentials.Standard Health Indicators
All provider data is transformed into standardized health indicators for consistency across devices:Activity Indicators
Activity Indicators
DAILY_STEPS: Step countDAILY_DISTANCE: Distance traveled (meters)DAILY_CALORIES_ACTIVE: Active calories burned (kcal)DAILY_CALORIES_BASAL: Basal metabolic rate calories (kcal)DAILY_FLOORS_CLIMBED: Floors climbed (count)ACTIVE_TIME: Active time duration (minutes)
Heart Rate Indicators
Heart Rate Indicators
HEART_RATE: Instantaneous heart rate (bpm)DAILY_HEART_RATE_MIN: Minimum daily heart rate (bpm)DAILY_HEART_RATE_MAX: Maximum daily heart rate (bpm)DAILY_AVG_HEART_RATE: Average daily heart rate (bpm)DAILY_HEART_RATE_RESTING: Resting heart rate (bpm)HRV: Heart rate variability RMSSD (ms)
Sleep Indicators
Sleep Indicators
DAILY_SLEEP_DURATION: Total sleep duration (ms)SLEEP_IN_BED: Time in bed (ms)DAILY_AWAKE_TIME: Time awake during sleep (ms)DAILY_LIGHT_SLEEP: Light sleep duration (ms)DAILY_DEEP_SLEEP: Deep sleep duration (ms)DAILY_REM_SLEEP: REM sleep duration (ms)SLEEP_EFFICIENCY: Sleep efficiency percentage
Body Metrics
Body Metrics
WEIGHT: Body weight (kg)HEIGHT: Height (m)BMI: Body mass indexBODY_FAT_PERCENTAGE: Body fat percentageSKELETAL_MUSCLE_MASS: Skeletal muscle mass (kg)
Respiratory Indicators
Respiratory Indicators
RESPIRATORY_RATE: Respiration rate (breaths/min)BLOOD_OXYGEN: SpO2 percentage
Workout Indicators
Workout Indicators
WORKOUT_DURATION_LOW: Low intensity duration (min)WORKOUT_DURATION_MEDIUM: Medium intensity duration (min)WORKOUT_DURATION_HIGH: High intensity duration (min)ALTITUDE_GAIN: Altitude gained (m)SPEED: Average speed (m/s)
For a complete list of standard indicators, see the
StandardIndicator enum in the mirobody framework documentation.Provider Requirements
To ensure quality and consistency, all providers must implement:- Required Methods
- Database Schema
- Configuration
Provider Discovery
Mirobody Health automatically discovers and loads providers from configured directories:Best Practices
Error Handling
Error Handling
- Always use try-except blocks for external API calls
- Log errors with context (user_id, timestamp, error details)
- Return empty results on failure, don’t crash
- Implement exponential backoff for transient errors
- Handle rate limiting gracefully
Data Validation
Data Validation
- Validate OAuth tokens before use
- Check data types before conversion
- Handle missing or null values gracefully
- Verify timestamp formats
- Validate units match expected values
Performance
Performance
- Use async/await for all I/O operations
- Implement pagination for large datasets
- Limit concurrent requests to vendor APIs
- Cache frequently accessed configuration
- Use connection pooling for database access
Security
Security
- Never log sensitive data (tokens, passwords)
- Store credentials encrypted in database
- Use HTTPS for all external communications
- Validate OAuth state parameters
- Implement token refresh for OAuth2