@wearlink/sdk
v0.1.0
Published
Official TypeScript/Node.js SDK for WearLink — unified connected-health data API.
Downloads
131
Maintainers
Readme
@wearlink/sdk
Official TypeScript / Node.js SDK for WearLink — a unified connected-health data API covering Garmin, Oura, Fitbit, WHOOP, Polar, Strava, Apple Health, Google Fit, and Samsung Health.
Install
npm install @wearlink/sdkRequires Node.js 18+ (uses native fetch). For older Node versions, pass your own fetch implementation.
Quick start
import { createWearLinkClient } from '@wearlink/sdk';
const wl = createWearLinkClient({ apiKey: process.env.WEARLINK_API_KEY! });
// Create an end-user
const user = await wl.users.create({
external_user_id: 'internal-abc-123',
email: '[email protected]',
first_name: 'Jane',
});
// Mint an SDK token for the mobile app to sync Apple Health data
const token = await wl.sdk.createUserToken(user.id, 'com.example.myapp');
// Later: pull the user's workouts
const workouts = await wl.data.workouts(user.id, {
start: '2026-04-01T00:00:00Z',
end: '2026-04-30T23:59:59Z',
});Webhook signature verification
import express from 'express';
import { verifyWebhookSignature } from '@wearlink/sdk';
const app = express();
app.post(
'/webhooks/wearlink',
express.raw({ type: 'application/json' }),
(req, res) => {
const ok = verifyWebhookSignature(
req.body,
req.header('x-webhook-signature'),
process.env.WEARLINK_WEBHOOK_SECRET!,
);
if (!ok) return res.sendStatus(401);
const event = JSON.parse(req.body.toString());
// ... handle event.type: 'workout.created', 'sleep.completed', etc.
res.sendStatus(200);
},
);Error handling
All non-2xx responses throw WearLinkError:
import { WearLinkError } from '@wearlink/sdk';
try {
await wl.users.get('nope');
} catch (err) {
if (err instanceof WearLinkError) {
console.log(err.status, err.detail);
}
}Configuration
createWearLinkClient({
apiKey: 'sk-...',
baseUrl: 'https://wearlink.io', // default
timeoutMs: 30_000, // default
fetch: customFetch, // default: globalThis.fetch
});License
MIT
