Error Response Format
All error responses follow a standardized JSON format:Common Error Codes & Their Causes
HTTP Status Code | Error Type | Description |
---|---|---|
400 Bad Request | Invalid Parameters | The request contains malformed or missing parameters. |
401 Unauthorized | Invalid API Key | Authentication is missing or incorrect. Ensure you include the Bearer token. |
403 Forbidden | Insufficient Permissions | The request is valid but the API key does not have access to the requested resource. |
404 Not Found | Resource Not Found | The requested endpoint or data does not exist. |
429 Too Many Requests | Rate Limit Exceeded | The request limit has been reached; slow down requests or upgrade your plan. |
500 Internal Server Error | Unexpected Error | A server-side issue occurred; retry later or contact support. |
Best Practices for Handling Errors
- Check Error Messages: Every error response includes a descriptive message to help pinpoint the issue.
- Implement Retries with Backoff: Use exponential backoff (e.g., 1s, 2s, 4s) when handling transient errors like
429 Too Many Requests
or500 Internal Server Error
. - Validate Requests Before Sending: Ensure required parameters are included and correctly formatted.
- Monitor Rate Limits: Avoid hitting rate limits by keeping track of API usage and applying caching strategies.
- Graceful Degradation: If an error occurs, provide fallback behavior (e.g., displaying cached data instead of failing completely).
- Log Errors: Capture and analyze errors to improve request handling and debug failures efficiently.