Skip to Content
API ReferenceHealth Data API

Health Data API

Lab upload, history, trends, and comparison endpoints available in the consumer app (my-loop-health).

Base URL: https://my.loop.health/api

Authentication: Clerk JWT bearer token.


Lab Upload

Upload Lab Report

Parse a lab report PDF or image into structured biomarker data.

curl -X POST "https://my.loop.health/api/labs/upload" \ -H "Authorization: Bearer $CLERK_JWT" \ -F "file=@lab-report.pdf"

Supported Formats: PDF, JPEG, PNG

Processing Pipeline:

  1. File uploaded and validated
  2. @loop/biomarker-parser extracts biomarkers via AI (Anthropic Claude)
  3. Raw biomarker names matched to canonical codes
  4. Units normalized to standard units
  5. Values classified against sex-specific reference ranges
  6. Results stored in the patient graph

Response:

{ "success": true, "data": { "id": "lab_xyz789", "labDate": "2024-06-01", "biomarkers": [ { "code": "testosterone-total", "name": "Total Testosterone", "value": 650, "unit": "ng/dL", "status": "normal", "referenceRange": { "low": 300, "high": 1000, "optimalLow": 500, "optimalHigh": 900 } }, { "code": "tsh", "name": "TSH", "value": 2.1, "unit": "mIU/L", "status": "optimal", "referenceRange": { "low": 0.4, "high": 4.0, "optimalLow": 1.0, "optimalHigh": 2.5 } } ], "summary": { "totalBiomarkers": 15, "optimal": 8, "normal": 5, "outOfRange": 2 } } }

Lab History

Get Lab History

curl -X GET "https://my.loop.health/api/labs/history" \ -H "Authorization: Bearer $CLERK_JWT"

Returns all lab reports for the authenticated user, ordered by date (newest first).

Get Single Lab Report

curl -X GET "https://my.loop.health/api/labs/:id" \ -H "Authorization: Bearer $CLERK_JWT"

Lab Comparison

Compare Two Lab Reports

curl -X GET "https://my.loop.health/api/labs/compare?labId1=lab_abc&labId2=lab_xyz" \ -H "Authorization: Bearer $CLERK_JWT"

Returns a side-by-side comparison of biomarker values between two lab reports, showing changes and trends.

Response:

{ "success": true, "data": { "lab1": { "id": "lab_abc", "date": "2024-01-15" }, "lab2": { "id": "lab_xyz", "date": "2024-06-01" }, "comparisons": [ { "code": "testosterone-total", "name": "Total Testosterone", "value1": 450, "value2": 650, "unit": "ng/dL", "change": 200, "changePercent": 44.4, "trend": "improving" } ] } }

curl -X GET "https://my.loop.health/api/labs/trends?biomarker=testosterone-total" \ -H "Authorization: Bearer $CLERK_JWT"

Returns historical values for a specific biomarker across all lab reports.

Response:

{ "success": true, "data": { "biomarker": "testosterone-total", "name": "Total Testosterone", "unit": "ng/dL", "dataPoints": [ { "date": "2024-01-15", "value": 450, "status": "normal" }, { "date": "2024-03-20", "value": 520, "status": "optimal" }, { "date": "2024-06-01", "value": 650, "status": "optimal" } ], "trend": "improving", "referenceRange": { "low": 300, "high": 1000, "optimalLow": 500, "optimalHigh": 900 } } }

Health Check-Ins

Submit Check-In

curl -X POST "https://my.loop.health/api/health/check-ins" \ -H "Authorization: Bearer $CLERK_JWT" \ -H "Content-Type: application/json" \ -d '{ "painLevel": 3, "sleepQuality": 7, "mood": 8, "energy": 6, "mobility": 8, "sideEffects": false, "notes": "Feeling good this week" }'

Weekly health check-ins contribute to the health score (30% weight) and are analyzed by Luna AI.


CGM Readings

Get CGM Readings

curl -X GET "https://my.loop.health/api/cgm/readings?from=2024-06-01&to=2024-06-15" \ -H "Authorization: Bearer $CLERK_JWT"

Returns continuous glucose monitor readings within the specified date range.

Get CGM Connections

curl -X GET "https://my.loop.health/api/cgm/connections" \ -H "Authorization: Bearer $CLERK_JWT"

Returns active CGM device connections (Dexcom, Libre).