Skip to main content
The Benzinga API uses conventional HTTP response codes to indicate the success or failure of an API request. In general:
  • 2xx: Success.
  • 4xx: Client error (e.g., missing parameter, invalid key).
  • 5xx: Server error (something went wrong on Benzingaโ€™s end).
Always check the HTTP Status Code first to determine if a request was successful. Do not rely solely on the response body, as the format can vary between different API endpoints.

HTTP Status Codes

The following table lists the standard status codes you may encounter.
CodeStatusDescription
200OKThe request was successful.
400Bad RequestThe request was unacceptable, often due to a missing or invalid parameter.
401UnauthorizedNo valid API Key provided. Check your Authorization header or token parameter.
402Request FailedThe parameters were valid but the request failed for business logic reasons.
403ForbiddenThe API Key is valid, but you do not have permission to access this resource.
404Not FoundThe requested resource (e.g., ID, endpoint) does not exist.
429Too Many RequestsYou have exceeded your rate limit.
500Internal Server ErrorSomething went wrong on Benzingaโ€™s servers. These are rare.
503Service UnavailableThe service is temporarily unavailable (e.g., maintenance).

Error Response Bodies

While the HTTP Status Code is the primary indicator of an error, the response body often contains details to help you debug. The format of this body can vary depending on which API you are calling.

Format 1: Simple Error Message

Many endpoints (like the News API) return a simple string or a flat JSON object with a message.
"Invalid or Missing Query Parameters"
OR
{
  "message": "Invalid page size"
}

Format 2: Structured Error Object

Newer APIs (like the Data API Proxy / Fundamentals) return a structured object containing a list of errors.
{
  "data": null,
  "errors": [
    {
      "code": "database_query_error",
      "id": "ERR_12345",
      "value": "Unable to fetch data for symbol: INVALID"
    }
  ],
  "ok": false
}

Handling Errors Programmatically

Because of the potential variance in response bodies, we recommend a robust error handling strategy:
  1. Check the HTTP Status Code. If it is >= 400, treat it as an error.
  2. Log the Response Body. Dump the entire body to your logs for debugging purposes.
  3. Display a Generic Message. Unless you are integrated with a specific endpoint and know its exact error format, show a generic โ€œSomething went wrongโ€ message to your end users alongside the Status Code.