Providers

Connect wearable devices and health data sources.

Supported Providers

ProviderAuthKey Metrics
FitbitOAuth 2.0HR, HRV, SpO2, steps, sleep, weight, temp, respiratory
GarminOAuth 2.0HR, HRV, SpO2, steps, sleep, stress, weight, VO2 max
WithingsOAuth 2.0HR, BP, SpO2, weight, body fat, temp, sleep, ECG
Apple HealthExport/bridgeHR, HRV, BP, glucose, temp, steps, sleep, ECG, VO2 max
Google FitOAuth 2.0HR, steps, sleep, weight, BP, glucose, SpO2, temp
Oura RingOAuth 2.0HR, HRV, SpO2, temp, respiratory, sleep, stress, steps
ManualNoneHR, BP, SpO2, glucose, weight, temp, sleep, steps

Provider Configuration

const config = {
  userId: "user-001",
  providers: [
    {
      provider: "fitbit",
      credentials: {
        provider: "fitbit",
        clientId: "your-client-id",
        clientSecret: "your-client-secret",
        accessToken: "oauth-access-token",
        refreshToken: "oauth-refresh-token",
      },
      syncIntervalMs: 900_000, // 15 minutes
      metrics: ["heart_rate", "steps", "sleep_duration"],
    },
  ],
};

HealthDataProvider Interface

All providers implement this interface:

interface HealthDataProvider {
  readonly name: ProviderType;
  readonly displayName: string;
  readonly supportedMetrics: MetricType[];

  authenticate(credentials): Promise<void>;
  refreshToken(): Promise<ProviderCredentials>;
  fetchData(metrics, from, to): Promise<VitalDataPoint[]>;
  isConnected(): boolean;
  disconnect(): void;
}

Provider Registry

import { ProviderRegistry } from "@vitalclaw/sdk";

const registry = ProviderRegistry.createDefault();

registry.getAll();                          // all 7 providers
registry.getConnected();                    // authenticated ones
registry.getSupportingMetric("heart_rate"); // providers with HR
registry.get("fitbit");                     // specific provider

Manual Data Entry

import { ManualProvider } from "@vitalclaw/sdk";

const manual = new ManualProvider();
manual.addEntry("user-001", "blood_pressure", 130, "mmHg", undefined, {
  systolic: 130,
  diastolic: 85,
});

const data = await manual.fetchData([], "", "");
engine.ingest(data);

FHIR R4 Interop

Export health data as FHIR R4 Observations using standardized LOINC codes:

import { FHIRConverter } from "@vitalclaw/sdk";

const fhir = new FHIRConverter();

// Single data point to FHIR Observation
const obs = fhir.toObservation(heartRatePoint);
// → { resourceType: "Observation", code: { coding: [{ system: "...", code: "8867-4" }] } ... }

// Batch export as FHIR Bundle
const bundle = fhir.toBundle(allDataPoints, "Patient/user-001");

// Import from FHIR
const point = fhir.fromObservation(observation);

// List supported LOINC mappings
fhir.getSupportedCodes();
// → [{ metric: "heart_rate", loinc: "8867-4", display: "Heart rate" }, ...]