Error Handling

Best practices for handling API errors and response codes.

5 min read Last updated: 2025-06-13

Common Error Codes

101: Invalid API key
102: Invalid endpoint
103: Required parameter missing
104: Rate limit exceeded
105: Subscription expired
106: Invalid parameter value
404: Resource not found
500: Internal server error

Error Response Format

All errors follow this format:
{
  "success": false,
  "error": {
    "code": 101,
    "info": "You have not supplied a valid API key."
  }
}

Handling Errors in Code

Example error handling in JavaScript:
fetch(url)
  .then(response => response.json())
  .then(data => {
    if (!data.success) {
      console.error(`Error ${data.error.code}: ${data.error.info}`);
      return;
    }
    // Process successful response
  })
  .catch(error => {
    console.error('Network error:', error);
  });

Retry Strategy

Implement exponential backoff for transient errors:
• First retry: 1 second
• Second retry: 2 seconds
• Third retry: 4 seconds
• Maximum retries: 3

Ready for the next step?

Continue learning with our next guide:

Next: Data Formats