Cadence API
A small, predictable REST API for your own Cadence data. Use it from scripts, integrations, or hand the generated SKILL.md to any AI assistant.
Base URL: https://cadence-ad3.pages.dev/v1 · All responses are JSON with an ok boolean. Timestamps are epoch milliseconds.
Authentication
Create a key in the app (Dashboard → API). Send it as a bearer token on every request:
Authorization: Bearer cad_live_xxxxxxxxxxxxxxxxxxxxxxxx
Keys are shown only once at creation and stored as salted hashes. Revoke instantly from the dashboard. Default scopes: records:read, records:write, analytics:read.
Data isolation & safety
A key only ever accesses the account that created it. Every request is authorized by the key owner’s id. There is no parameter, endpoint, or trick that lets a key read, modify, or discover another user’s account, records, or analytics — and keys carry no admin capability.
Errors & rate limits
Errors return a non-2xx status and { "ok": false, "error": "...", "code": "..." }. Rate limit: 120 requests/minute per key (HTTP 429 when exceeded).
| Status | Meaning |
|---|---|
| 200 / 201 | Success |
| 401 | Missing/invalid key |
| 403 | Missing scope |
| 404 | Not found |
| 422 | Validation error |
| 429 | Rate limited |
Account
/v1/meReturns the account and key metadata. Use it to verify a key.
curl https://cadence-ad3.pages.dev/v1/me \ -H "Authorization: Bearer cad_live_..."
Records
type ∈ cigarette · patch · gum · lozenge · caffeine · protein · calories. The server computes derived metrics (nicotine_mg, caffeine_mg, protein_g, calories_kcal).
/v1/records — query: type, from, to, limit, offset/v1/records/v1/records/:id/v1/records/:id/v1/records/:idcurl -X POST https://cadence-ad3.pages.dev/v1/records \
-H "Authorization: Bearer cad_live_..." \
-H "Content-Type: application/json" \
-d '{"type":"cigarette","quantity":1,"trigger":"coffee"}'
curl -X POST https://cadence-ad3.pages.dev/v1/records \
-H "Authorization: Bearer cad_live_..." -H "Content-Type: application/json" \
-d '{"type":"caffeine","quantity":1,"meta":{"source":"brewed_coffee"}}'
| Field | Type | Notes |
|---|---|---|
| type | string | required |
| quantity | number | count / pieces / grams / kcal / servings |
| occurred_at | number | epoch ms; defaults to now; backfill allowed |
| trigger, mood, note | string | optional |
| meta | object | strength, brand, source, mg, food name, macros… |
Analytics
/v1/analytics?range=7d|30d|90dDaily series + totals for your account: per-metric sums, today, last 24h, type & trigger breakdowns, goal progress.
curl "https://cadence-ad3.pages.dev/v1/analytics?range=30d" \ -H "Authorization: Bearer cad_live_..."
Insights
/v1/insightsThe deterministic 24h / 2d / 7d trend summary with arrows, gentle flags, and correlation callouts (optionally AI-polished). Scoped to your account.
SKILL.md for AI assistants
When you create a key, Cadence generates a SKILL.md file you can download and drop into any AI assistant. It contains the software name, your key, full usage instructions, and the isolation guarantee — so an AI can safely operate only your account.
- The embedded key is bound to one account — yours.
- It can’t reach any other user’s data; the server authorizes by owner id.
- No admin powers; scoped to records + analytics only.
- Revoke it anytime and the SKILL.md stops working instantly.