The API
REST over HTTPS, JSON in and out, every endpoint under /api/v3.
REST over HTTPS, JSON in and out, and every v3 endpoint under /api/v3 on one
of two hosts. See base URLs.
Use the API for calls, not for the whole flow
Quotes, checkout URLs, order status: call those directly, and most integrations do. Just don't build the whole customer flow on the API. It keeps changing, often for regulatory reasons like an extra verification step, and a pure API integration has to be rebuilt each time. Unified Checkout and the widget pick those changes up for you.
Conventions
These hold across every endpoint, so they are worth reading once.
- Amounts are strings
- Never JSON numbers. Parsing 0.00234118 as a float and sending it back loses precision.
- Rates are fractions
- 0.015 means 1.5%. Multiplying by 100 twice is the mistake this line exists to prevent.
- Currencies are identifiers
- CAIP-19 for the asset, CAIP-2 for the chain. Not tickers, and not our old codes.
- Identifiers are opaque
- Store them as strings. Do not parse one, and do not assume a length or a format.
- Timestamps are UTC
- RFC 3339, always with a Z.
Currency identifiers are the change that catches people first. The crypto and chains reference lists every one we support, and what changed since v1 and v2 explains why they replaced the old codes.
Errors
Branch on the HTTP status. That is the part you can rely on.
The body carries a human-readable reason, but its shape is not uniform yet: an
authentication failure answers {"code", "message"}, a validation failure
answers {"error"}. Handle both, and log the text rather than matching on it.
See authentication for what produces a 401 or a 403.
Endpoint pages are generated
Every endpoint under API is generated from the published document, not hand-written. What you see there matches the spec by construction.