跳转到主要内容

概览

Providers 让你将可穿戴设备与健康平台连接到 Mirobody Health。连接完成后,你的健康数据会自动同步,并可用于 AI 分析。

Garmin Connect

全面的运动与健康追踪

Whoop

恢复、负荷(strain)与睡眠优化
更多 providers 即将上线。你也可以自己添加自定义 providers

连接一个 Provider

1

获取设备凭据

从健康设备 provider 获取 API 凭据:
你需要这些凭据来完成 provider 连接配置。
2

配置 provider

将凭据写入 config.yaml
config.yaml
# For Garmin
GARMIN_CLIENT_ID: 'your_consumer_key'
GARMIN_CLIENT_SECRET: 'your_consumer_secret'
GARMIN_REDIRECT_URL: 'http://localhost:18080/api/v1/pulse/theta/theta_garmin/callback'

# For Whoop
WHOOP_CLIENT_ID: 'your_client_id'
WHOOP_CLIENT_SECRET: 'your_client_secret'
WHOOP_REDIRECT_URL: 'http://localhost:18080/api/v1/pulse/theta/theta_whoop/callback'
3

链接账号

使用 API 发起 OAuth flow:
# Get authorization URL
curl "http://localhost:18080/api/v1/pulse/theta/theta_garmin/link?user_id=YOUR_USER_ID"
访问返回的 URL 完成授权。
4

验证连接

检查 provider 是否已链接:
curl "http://localhost:18080/api/v1/pulse/providers"
已连接的 provider 应显示 "status": "connected"

可用 Providers

Garmin Connect

Authentication: OAuth 1.0
Status: Production Ready
Data Sync: Automatic daily sync
Garmin Connect 可从 Garmin 可穿戴设备中提供全面的健康数据,包括运动手环、智能手表与骑行电脑等。
Garmin 数据包含详细的活动追踪、高级睡眠分析以及全面的心率指标。

Whoop

Authentication: OAuth 2.0
Status: Production Ready
Data Sync: Automatic sync with configurable frequency
Whoop 专注于恢复、负荷(strain)与睡眠优化数据,帮助你评估训练准备度与表现。
Whoop 在恢复指标、睡眠指导与负荷追踪方面表现突出,适合运动员与健身爱好者。

管理已连接的 Providers

List All Providers

curl http://localhost:18080/api/v1/pulse/providers

Disconnect a Provider

curl -X POST http://localhost:18080/api/v1/pulse/theta/theta_garmin/unlink \
  -H "Content-Type: application/json" \
  -d '{"user_id": "YOUR_USER_ID"}'

数据同步

当 provider 连接完成后,数据会自动同步:
首次连接 provider 时,Mirobody Health 会拉取历史数据:
  • Garmin: Last 30 days of data
  • Whoop: Last 30 days of data
视数据量而定,可能需要几分钟。
初次同步完成后,数据会自动更新:
  • Schedule: Daily at configured intervals
  • Incremental: Only new data is fetched
  • Deduplication: Prevents duplicate records
如有需要,你也可以通过 API 手动触发同步。
所有 provider 数据都会被转换为标准化指标:
  • Providers 间统一命名
  • 统一单位(SI system)
  • 时间戳使用 ISO 8601 格式
  • 存储在 theta_ai.th_series_data 表中
详情参见数据格式

故障排查

Problem:OAuth 授权失败或超时Solutions
  1. Verify API credentials are correct in config.yaml
  2. Check redirect URL matches exactly (including http/https)
  3. Ensure Mirobody Health is accessible at the redirect URL
  4. Review provider’s developer console for errors
  5. Check OAuth token hasn’t expired
Problem:Provider 已连接但没有数据Solutions
  1. Wait for initial sync to complete (check logs)
  2. Verify user has data in their provider account
  3. Check for API rate limiting issues
  4. Review sync logs for errors
  5. Trigger manual sync if needed
Problem:健康数据过期或未更新Solutions
  1. Check sync schedule in configuration
  2. Verify provider API is accessible
  3. Review sync logs for failures
  4. Check for provider API changes or downtime
  5. Trigger manual resync

Provider 状态

检查 provider 连接状态:
import aiohttp

async def check_provider_status(user_id: str):
    async with aiohttp.ClientSession() as session:
        async with session.get(
            f"http://localhost:18080/api/v1/pulse/providers",
            params={"user_id": user_id}
        ) as resp:
            data = await resp.json()
            
            for provider in data["providers"]:
                print(f"{provider['name']}: {provider['status']}")
                if provider['status'] == 'connected':
                    print(f"  Last sync: {provider.get('last_sync', 'N/A')}")

# Usage
await check_provider_status("your_user_id")

Next Steps