Libre CGM Integration
FreeStyle Libre continuous glucose monitors provide glucose data through LibreView or Terra API integration.
OAuth Setup
Prerequisites
- Set up a LibreView or Terra API account
- Register your application for CGM data access
- Set the redirect URI to
https://my.loop.health/api/cgm/libre/callback
Environment Variables
LIBRE_CLIENT_ID=your-libre-client-id
LIBRE_CLIENT_SECRET=your-libre-secret
LIBRE_REDIRECT_URI=https://my.loop.health/api/cgm/libre/callbackSupported Devices
| Device | Status |
|---|---|
| FreeStyle Libre 1 | Supported |
| FreeStyle Libre 2 | Supported |
| FreeStyle Libre 3 | Supported |
Connection Flow
Step 1: Initiate Connection
curl -X GET "https://my.loop.health/api/cgm/libre/connect" \
-H "Authorization: Bearer $CLERK_JWT"Redirects the user to the LibreView/Terra authorization page.
Step 2: OAuth Callback
GET /api/cgm/libre/callback?code=AUTH_CODE&state=STATE_TOKENData Collected
Glucose Readings
{
"metricType": "glucose",
"source": "libre",
"metrics": {
"value": 98,
"unit": "mg/dL",
"trend": "flat",
"scanType": "automatic"
}
}Reading Types
| Type | Description |
|---|---|
automatic | Automatic readings every 1–5 minutes |
scan | Manual scan by user |
historic | Backfilled historical data |
Data Sync
Libre data is synced on the same schedule as Dexcom — every 30 minutes via the syncCgmReadings Trigger.dev job.
Libre vs. Dexcom
| Feature | Libre | Dexcom |
|---|---|---|
| Real-time alerts | Libre 3 only | All models |
| Scan required | Libre 1/2 | No |
| Sensor duration | 14 days | 10 days (G6), 10–15 days (G7) |
| Warm-up | 1 hour | 2 hours |
| Reading interval | 1–5 min | 5 min |