stdout is JSON, always
One JSON document, an NDJSON stream ending in a summary line, or an error envelope. Never a table, never a spinner, never a half-line. Pass --pretty when a person is reading.
One manifest instead of --help
wcli schema prints every command, flag, enum, OAuth scope, output shape and exit code as JSON, reflected off the command tree of the binary that is running.
$ wcli schema --summary # compact index
$ wcli schema weight # one command in full
$ wcli schema # everything
A typed error envelope
Every failure has the same shape, and kind always agrees with the process exit code. Branch on either, and read hint for the next step. When Withings itself refused the call, status carries its status number. This one is real output, wrapped to fit.
$ wcli weight # before logging in; exit code 2
{"error":{"kind":"auth","code":2,
"reason":"no_credentials",
"message":"no Withings credentials are configured",
"hint":"run 'wcli auth login', or set WITHINGS_TOKEN to an access token"}}
Streams that say when they are done
--all follows pagination and streams one record per line, then exactly one summary line. If a later page fails, the summary still arrives with "ok":false and the error inside. Example data, records shortened.
$ wcli bp --all
{"key":"systolic_bp","value":118,"unit":"mmHg",...}
{"key":"diastolic_bp","value":76,"unit":"mmHg",...}
{"key":"heart_pulse","value":61,"unit":"bpm",...}
{"command":"bp","count":3,"ok":true,"requests":2,"type":"summary"}
Secrets stay out of the context window
OAuth tokens and your client secret live in the operating system keyring (macOS Keychain, Windows Credential Manager, Secret Service on Linux), or in an encrypted file where no keyring is reachable. The 3-hour access token is refreshed for you, and the managed commands never print a token. For a script, WITHINGS_TOKEN supplies an access token directly.
stderr is sanitized
Progress and a readable copy of any error go to stderr, stripped of ANSI escapes, bidi and zero-width characters. An agent never needs to parse it to know whether a call worked.
A dry run for every raw command
--dry-run validates the flags, prints the exact request with secrets redacted and sends nothing. It needs no credentials. Real output:
$ wcli notify subscribe --appli 1 \
--callbackurl https://example.com/hook --dry-run --pretty
{
"dry_run": true,
"sent": false,
"endpoint": "notify subscribe",
"mutating": true,
"auth": "bearer",
"method": "POST",
"url": "https://wbsapi.withings.net/notify",
"headers": {
"Authorization": "Bearer <redacted>",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "withings-cli/0.3.1"
},
"params": {
"action": "subscribe",
"appli": "1",
"callbackurl": "https://example.com/hook"
}
}
The awkward parts of the API, handled once
Withings answers every call with HTTP 200 and a status number in the body, encodes measures as value × 10^unit, wants epoch seconds on some endpoints and YYYY-MM-DD on others, keys intraday and sleep series by epoch seconds, and returns almost nothing for activity and sleep unless you name the fields.
The CLI maps the status to the error envelope, decodes the measures, accepts YYYY-MM-DD, RFC 3339 or unix seconds on any date flag, returns those series as lists sorted by time, and asks for every documented field by default. The endpoints limited to 24 hours per call refuse a longer window instead of silently dropping data; --all walks it in 24-hour chunks.