Skip to content

Sleep Analysis & Biometrics

import { Aside } from ‘@astrojs/starlight/components’;

VitaSync provides advanced sleep analysis, rolling biometric baselines, composite health scores, periodic health snapshots, and AI-generated insights — all computed from synced wearable data.

Go beyond raw sleep metrics with computed sleep debt and quality analysis.

Calculates accumulated sleep debt based on a target of 8 hours per night.

Terminal window
curl http://localhost:3001/v1/users/$USER_ID/sleep-analysis/debt?days=14 \
-H "Authorization: Bearer $API_KEY"

Response:

{
"totalDebtMinutes": 180,
"averageSleepMinutes": 420,
"targetSleepMinutes": 480,
"dailyDeficitMinutes": -60,
"trend": "worsening",
"days": 14
}

Comprehensive sleep quality analysis over a configurable period.

Terminal window
curl http://localhost:3001/v1/users/$USER_ID/sleep-analysis/quality?days=30 \
-H "Authorization: Bearer $API_KEY"
MethodPathDescription
GET/v1/users/:userId/sleep-analysis/debtSleep debt calculation (days param, default 14)
GET/v1/users/:userId/sleep-analysis/qualitySleep quality report (days param, default 30)

Rolling statistical baselines for every health metric. Baselines power anomaly detection and trend analysis.

  1. Aggregates metric values over a 30-day rolling window
  2. Computes: mean, standard deviation, min, max, median, 25th/75th percentiles
  3. Determines trend direction and slope
  4. Updates after each sync
Terminal window
curl http://localhost:3001/v1/users/$USER_ID/baselines \
-H "Authorization: Bearer $API_KEY"

Response:

{
"data": [
{
"metricType": "resting_heart_rate",
"mean": 58.2,
"stddev": 3.1,
"min": 52,
"max": 65,
"median": 58,
"p25": 56,
"p75": 60,
"sampleSize": 30,
"trend": "decreasing",
"trendSlope": -0.12
}
]
}
Terminal window
curl http://localhost:3001/v1/users/$USER_ID/baselines/resting_heart_rate \
-H "Authorization: Bearer $API_KEY"
Terminal window
curl -X POST http://localhost:3001/v1/users/$USER_ID/baselines/compute \
-H "Authorization: Bearer $API_KEY"
MethodPathDescription
GET/v1/users/:userId/baselinesList all baselines (optional metricType filter)
GET/v1/users/:userId/baselines/:metricTypeGet baseline for a specific metric
POST/v1/users/:userId/baselines/computeRecompute all baselines

Composite scores derived from multiple metrics, updated after each sync.

Sub-scoreBased on
OverallWeighted average of all sub-scores
SleepDuration, efficiency, stage balance, consistency
ActivitySteps, active minutes, calories, workout frequency
CardioResting HR, HRV, VO₂ max trends
RecoveryRecovery score, strain balance, readiness
BodyWeight trend, body composition stability
Terminal window
curl http://localhost:3001/v1/users/$USER_ID/health-scores/latest \
-H "Authorization: Bearer $API_KEY"

Response:

{
"overallScore": 82,
"sleepScore": 78,
"activityScore": 85,
"cardioScore": 80,
"recoveryScore": 84,
"bodyScore": 79,
"grade": "B+",
"deltaFromPrevious": 3,
"weeklyAverage": 80,
"percentileRank": 72,
"date": "2025-03-18T00:00:00.000Z"
}
Terminal window
curl "http://localhost:3001/v1/users/$USER_ID/health-scores?from=2025-03-01T00:00:00Z&limit=30" \
-H "Authorization: Bearer $API_KEY"
MethodPathDescription
GET/v1/users/:userId/health-scores/latestLatest composite score
GET/v1/users/:userId/health-scoresScore history (filter by from, to, limit)
POST/v1/users/:userId/health-scores/computeTrigger score computation

Point-in-time summaries aggregating all key metrics for a period.

Terminal window
# Weekly snapshot
curl -X POST http://localhost:3001/v1/users/$USER_ID/snapshots/generate/weekly \
-H "Authorization: Bearer $API_KEY"
# Monthly snapshot
curl -X POST http://localhost:3001/v1/users/$USER_ID/snapshots/generate/monthly \
-H "Authorization: Bearer $API_KEY"

Each snapshot includes averaged values for: steps, sleep minutes, resting heart rate, HRV, calories, active minutes, weight, stress, recovery, workout count, total distance, goal completion rate, and mood score.

MethodPathDescription
GET/v1/users/:userId/snapshotsList snapshots (filter by periodType)
GET/v1/users/:userId/snapshots/:snapshotIdGet a specific snapshot
POST/v1/users/:userId/snapshots/generate/weeklyGenerate weekly snapshot
POST/v1/users/:userId/snapshots/generate/monthlyGenerate monthly snapshot

AI-generated health insights derived from patterns in your data.

Terminal window
curl "http://localhost:3001/v1/users/$USER_ID/insights?from=2025-03-01T00:00:00Z" \
-H "Authorization: Bearer $API_KEY"

Response:

{
"data": [
{
"type": "trend",
"title": "Resting heart rate improving",
"description": "Your resting HR has decreased 4.2% over the past 2 weeks, suggesting improving cardiovascular fitness.",
"confidence": 0.85,
"relatedMetrics": ["resting_heart_rate"]
},
{
"type": "correlation",
"title": "Sleep quality affects recovery",
"description": "Days with 7+ hours of sleep show 23% higher recovery scores on average.",
"confidence": 0.78,
"relatedMetrics": ["sleep_duration", "recovery_score"]
}
],
"total": 2
}
Terminal window
curl http://localhost:3001/v1/insights/algorithms \
-H "Authorization: Bearer $API_KEY"
MethodPathDescription
GET/v1/users/:userId/insightsGenerate insights (optional from, to)
GET/v1/insights/algorithmsList available insight algorithms