Error Handling
The Color API returns standard HTTP status codes and detailed error information in JSON format.
Error Response Format
Section titled “Error Response Format”{ "error": { "code": "error_code_here", "message": "Human-readable error message", "details": ["Additional context or validation errors"] }}HTTP Status Codes
Section titled “HTTP Status Codes”| Status | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 404 | Not Found - Endpoint doesn’t exist |
| 429 | Rate Limit Exceeded |
| 500 | Internal Server Error |
Common Error Codes
Section titled “Common Error Codes”| Code | Description |
|---|---|
invalid_color_format |
The color value provided is not a valid format |
missing_parameter |
Required parameter is missing |
invalid_parameter |
Parameter value is invalid |
rate_limit_exceeded |
Too many requests |
authentication_failed |
Invalid API key |
Handling Errors
Section titled “Handling Errors”try { const response = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` }, });
if (!response.ok) { const error = await response.json(); console.error("API Error:", error.error.message); }} catch (e) { console.error("Network error:", e);}