Error Handling
The DITBlogs API uses conventional HTTP status codes to indicate the success or failure of an API request. In general, codes in the 2xx
range indicate success, 4xx
range indicate a client-side error (e.g., a bad parameter), and 5xx
range indicate a server-side error.
HTTP Status Codes
Status Code | Description |
---|---|
200 OK | The request was successful. |
201 Created | The resource was successfully created (e.g., after a POST request). |
400 Bad Request | The request was malformed, such as having missing or invalid parameters. |
401 Unauthorized | Authentication failed. The API key is missing or invalid. |
403 Forbidden | Authentication succeeded, but you do not have permission (e.g., exceeded usage hard limit). |
404 Not Found | The requested resource does not exist. |
429 Too Many Requests | You have hit the rate limit. Please slow down your requests. |
500 Internal Server Error | Something went wrong on our end. Please try again later. |
Error Response Body
When an error occurs, the API will respond with a JSON object containing an error
key. For validation errors (400), the value may be an object detailing the specific fields.
400 Bad Request
json
{
"error": {
"postSlug": ["Post slug is required."]
}
}
401 Unauthorized
json
{ "error": "Unauthorized: Invalid API key." }
403 Forbidden
json
{ "error": "Usage limit exceeded. Your plan's hard limit is 100,000 views per month." }
404 Not Found
json
{ "error": "Post not found." }
429 Too Many Requests
json
{ "error": "Too Many Requests." }
500 Internal Server Error
json
{ "error": "Internal Server Error" }