SDKs and OpenAPI
Every /v1 endpoint is described in one OpenAPI 3.1 file at /openapi.json. Point any OpenAPI tool at it to get a typed client. The official TypeScript package is built from the same file.
Key facts
- Spec: /openapi.json
- Format: OpenAPI 3.1
- Covers: every /v1 endpoint
- TypeScript package: @tryready/sdk
The whole /v1 API is described in one file: https://docs.tryready.com/openapi.json (OpenAPI 3.1). It lists every endpoint, its parameters, its request body, what it returns and the errors it can answer. A check compares it with the routes the API serves, so a route missing from the file is caught.
Our TypeScript package is generated from this file, not written by hand, so its methods match the API.
#TypeScript and Node
Install the official TypeScript package from npm:
npm install @tryready/sdk
It works in Node 18 and later, Deno, Bun and edge runtimes, and has no dependencies.
What it does for you:
- One setup line. Your API key, the base URL and a sub-account go in the constructor. The key defaults to the
READY_API_KEYenvironment variable. - Safe retries. Every
POSTcarries anIdempotency-Key, the same one on every try. It retries twice by default, waitsRetry-Afterwhen the API sends it, and only retries an answer where nothing ran or where the key makes a second try harmless (When to retry). - Typed errors. A refusal throws an error with
status,codeandrequestId, one class per status (RateLimitError,PaymentRequiredErrorand so on). - Every page of a list.
for awaitwalks the pages and stops whenhas_moreis false. - Webhook checks. One call checks the signature of an event and parses it (Verifying the signature).
#Generate a client today
Any OpenAPI tool can read the file. Two that need no account:
# TypeScript types for every endpoint, used with the small openapi-fetch client
npx openapi-typescript https://docs.tryready.com/openapi.json -o ./ready-api.d.ts
# a full client in Python, Go, Java, PHP, Ruby, C# and more (needs Java or Docker)
npx @openapitools/openapi-generator-cli generate -i https://docs.tryready.com/openapi.json -g python -o ./ready-client
Whatever you generate, set these yourself:
- Send the key as
X-API-KeyorAuthorization: Bearer(Authentication). - Agencies add
X-Sub-Account-Idto act as a sub-account (Acting as a sub-account). - Keep the base URL a setting, so you can point the same code at another host.
- Send one
Idempotency-Keyper text, kept across retries, so a retry never sends twice.
#Reading the file
- Responses keep the shape the API sends:
"success": trueand the result indata, with paging fields next to it. Errors use theErrorschema (Errors). x-ready-idempotent: truemarks the endpoints where a repeatedIdempotency-Keyreplays the first answer.x-ready-paginationon a list says how it pages: which parameter takes the cursor or offset, and which fields say there is more.- Response fields are open: new fields and new status values can appear in
/v1at any time (Versioning). Don’t make a generated client reject a value it doesn’t know.