HTTP Status Codes
2xx: Success
- 200 OK: The request was successful, and the server returned the expected response.
4xx: Client Errors
These errors indicate an issue with the client’s request:- 400 Bad Request: The request is malformed or contains invalid parameters.
- 401 Unauthorized: The Bearer API key is missing or invalid (returned once API-key enforcement is enabled).
- 403 Forbidden: The client does not have permission to access the requested resource.
- 404 Not Found: The requested resource could not be found.
- 429 Too Many Requests: The client has exceeded the allowed rate limit.
5xx: Server Errors
These errors indicate an issue on the server side:- 500 Internal Server Error: An unexpected error occurred on the server.
- 502 Bad Gateway: The server received an invalid response from an upstream server.
- 503 Service Unavailable: The service is temporarily unavailable, possibly due to maintenance or overload.
Error Response Format
The API returns three distinct error envelopes depending on where the request failed.Application errors
Business and application errors (invalid parameters, missing resources, conflicts, rate limits, server errors) return a structured envelope:error_code(string): Stable, machine-readable error code (e.g.PAIR_NOT_FOUND,VALIDATION_ERROR,NOT_FOUND,RATE_LIMIT_EXCEEDED,INTERNAL_ERROR).message(string): Human-readable description of the error.details(object): Optional structured context about the error (may be empty).request_id(string): Request correlation identifier — include it when contacting support.
Request-validation errors (HTTP 422)
Requests that fail schema validation before reaching application logic return FastAPI’s validation envelope with HTTP422:
detail(array<object>): One entry per validation failure.loc(array<(string | integer)>): Path to the offending field.msg(string): Validation error message.type(string): FastAPI/Pydantic validation error type.
Legacy errors
A few endpoints still return some400 responses as a bare detail object, without error_code or request_id — for example an unsupported route on POST /market/quote or a malformed pair_ticker filter on GET /market/pairs:
detail(string): Human-readable description of the error.
400 responses should accept both the structured envelope and this legacy shape.
Common Errors
Here are some typical errors and their resolutions:400 Bad Request
- Cause: Missing or invalid parameters in the request.
- Solution: Verify the request payload and ensure all required fields are provided with valid data.
404 Not Found
- Cause: The requested endpoint or resource does not exist.
- Solution: Check the endpoint URL and resource identifiers.
429 Too Many Requests
- Cause: The client has sent too many requests in a short period.
- Solution: Implement rate-limiting in your client application and retry after the specified wait time (if provided).
500 Internal Server Error
- Cause: An unexpected error occurred on the server.
- Solution: Retry the request later. If the issue persists, contact support with details about the request.
WebSocket Error Handling
For WebSocket connections, errors are communicated as JSON messages. If a critical error occurs, the server may close the connection.Reconnection Strategy
If a WebSocket connection is closed unexpectedly:- Wait for a few seconds (e.g., 5-10 seconds).
- Re-establish the connection.
- Re-issue any pending
quote_requestmessages to obtain fresh quotes.
Debugging Tips
- Check Logs: Monitor your application logs for details about failed requests.
- Validate Inputs: Ensure all request parameters and payloads meet the API requirements.
- Contact Support: For persistent or unclear errors, provide the following details:
- Request URL
- HTTP method
- Request payload
- Timestamp of the error
- Full error response from the API
Best Practices
- Handle Errors Gracefully: Implement proper error-handling logic in your application to avoid crashes or user frustration.
- Rate-Limiting: Respect the API rate limits to avoid
429 Too Many Requestserrors. - Retry Mechanism: For transient errors (e.g., 500 Internal Server Error), implement a retry mechanism with exponential backoff.
For additional details on error codes and troubleshooting, refer to the API documentation.