The Tern API is built around one thing: the quote. You get a price, ask for a firm quote, have the user deposit or send the swap, follow the quote, and for a cross-chain swap, reveal the secret that completes it. Every quote endpoint, and every webhook, returns the same quote object.

Base URL

Every path starts with /v1. Requests and responses are JSON over HTTPS.

Endpoints

Formats

New fields, error codes, and values may be added to v1 over time. Ignore fields you don’t recognize, and handle an unfamiliar error code by its HTTP status.

Calling from a browser

The API accepts requests from any website, so a web app can call it directly. Browsers can send the x-api-key, Idempotency-Key, and x-request-id headers, and read the x-request-id, Retry-After, Location, and Idempotent-Replayed headers in responses.

The OpenAPI document

The whole API is described in OpenAPI 3.1, with examples, every field and enum value documented, and an operation ID per endpoint (getPrice, createQuote, getQuote, …). Generate a client from it in your language.

Rules for every request

Authentication and limits

API keys, rate limits, and request IDs.

Idempotency

Retry safely without creating anything twice.

Errors

What each error means and how to handle it.