Errors
The API uses standard HTTP status codes and a consistent error envelope, so you can handle every failure the same way.
Error envelope
Section titled “Error envelope”Errors share the response envelope but carry a message instead of data:
{ "success": false, "statusCode": 403, "code": "invalid_api_key", "message": "API key is invalid or missing to access to the requested resource"}| Field | Type | Description |
|---|---|---|
success | boolean | Always false for errors. |
statusCode | integer | Mirrors the HTTP status code. |
code | string | Stable, machine-readable error code. |
message | string | Human-readable explanation. |
Handling errors
Section titled “Handling errors”Branch on success (or statusCode) rather than parsing the message text:
const body = await res.json();if (!body.success) { // body.code is stable; body.message is for humans/logs throw new Error(`${body.code}: ${body.message}`);}Common statuses
Section titled “Common statuses”| Status | Typical code | Meaning |
|---|---|---|
403 | invalid_api_key | Token missing or invalid — see Authentication. |
404 | not_found | The requested resource does not exist. |