Skip to main content

Success envelope

Every successful REST response is wrapped in the same envelope. data holds the endpoint’s payload, which can be an object or an array.
POST endpoints answer with HTTP 200, not 201.
Exception: Pulse views. POST /pulse/views and POST /pulse/views/pagination return raw JSON with no status/data envelope, for example {"new":{"data":[...]}}. Their errors still use the error envelope below. The native POST /pulse endpoint uses the normal envelope.

Error envelope

Errors return a non-2xx HTTP status and this body:
string
required
Always "error".
number
required
Same value as the HTTP status code.
string
required
Machine-readable error code. One of the values in Error codes.
string
required
Human-readable description. For validation errors it lists every problem (see below).
array | object
Extra information. Present on validation errors ([{ field, message }]) and on some 503 responses (a status report). Omitted when there is nothing to add.
404 example
Branch on code, not on message. Messages can change.

Error codes

The code field can hold any of these values: INVALID_PARAMETERS, INVALID_ADDRESS, TOKEN_NOT_FOUND, POOL_NOT_FOUND, ASSET_NOT_FOUND, BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, RATE_LIMITED, SERVICE_UNAVAILABLE, INTERNAL_ERROR These are the codes the REST API emits today:
UNAUTHORIZED, FORBIDDEN and RATE_LIMITED exist in the enum but are not emitted today: the REST API currently has no authentication and no rate limiting. Handle them generically so your client keeps working if they are introduced.
BAD_REQUEST is used for other 400 responses that are not parameter validation failures. Any HTTP status without its own code (for example 405) is returned with code INTERNAL_ERROR but keeps its real statusCode, so check statusCode as well as code.

Validation errors

Query strings and request bodies are validated before anything else runs. A failure returns HTTP 400 with:
  • details: one { field, message } entry per problem. field is the dotted path of the parameter, for example limit, chain or 0.address for the first item of a batch body. It is "" for problems with the whole body.
  • message: every detail joined with "; ", each written as field: message (or just message when field is empty).
  • code: INVALID_ADDRESS only when every problem is an address problem. Anything else, including a bad address combined with another bad parameter, gives INVALID_PARAMETERS.

Examples

Bad address only, GET /token?address=0x123&chain=1:
Bad address and bad chain, GET /token?address=0x123&chain=abc:
Missing parameters, GET /token:
Limit too big and reversed time range, GET /trades?...&limit=500&from=10&to=5:
Malformed cursor, GET /trades?...&cursor=zzz:
Empty batch body, POST /market/details with []:
Missing search input, GET /search:
Unsupported chain on GET /wallet/holdings?chain=137&... (no details):
Messages written by ChainQuery (such as must be a chain id like 1 or evm:1 or from must be before to) are stable. Generic messages such as Invalid input: expected string, received undefined or Too big: expected number to be <=100 come from the validation library’s defaults, and their wording may change. Match on code and field, not on the message text.

Pulse views use string details

On POST /pulse/views and POST /pulse/views/pagination, errors found while interpreting the views (unsupported filters, unknown chains, duplicate names) return details as an array of strings instead of { field, message } objects:
Each string is path: message. Handle both shapes if you call several endpoints. See Pulse REST views.

WebSocket errors

The WebSocket surfaces do not use HTTP status codes. They send error messages on the open connection and use WebSocket close codes for connection-level problems: