readyDocs Open the app

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_KEY environment variable.
  • Safe retries. Every POST carries an Idempotency-Key, the same one on every try. It retries twice by default, waits Retry-After when 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, code and requestId, one class per status (RateLimitError, PaymentRequiredError and so on).
  • Every page of a list. for await walks the pages and stops when has_more is 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-Key or Authorization: Bearer (Authentication).
  • Agencies add X-Sub-Account-Id to 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-Key per text, kept across retries, so a retry never sends twice.

#Reading the file

  • Responses keep the shape the API sends: "success": true and the result in data, with paging fields next to it. Errors use the Error schema (Errors).
  • x-ready-idempotent: true marks the endpoints where a repeated Idempotency-Key replays the first answer.
  • x-ready-pagination on 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 /v1 at any time (Versioning). Don’t make a generated client reject a value it doesn’t know.