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 CodeDescription
200 OKThe request was successful.
201 CreatedThe resource was successfully created (e.g., after a POST request).
400 Bad RequestThe request was malformed, such as having missing or invalid parameters.
401 UnauthorizedAuthentication failed. The API key is missing or invalid.
403 ForbiddenAuthentication succeeded, but you do not have permission (e.g., exceeded usage hard limit).
404 Not FoundThe requested resource does not exist.
429 Too Many RequestsYou have hit the rate limit. Please slow down your requests.
500 Internal Server ErrorSomething 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" }