Exceptions
Custom exceptions to catch various HTTP codes returned by the OpenAQ API.
ApiKeyMissingError
Bases: OpenAQError
API Key missing error.
BadRequestError
Bases: HTTPClientError
HTTP 400 - Client request error.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
int
|
HTTP status code |
BadGatewayError
Bases: ServerError
HTTP 502 - Indicates that the gateway or proxy received an invalid response from the upstream server.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[502]
|
HTTP status code |
ForbiddenError
Bases: HTTPClientError
HTTP 403 - Forbidden.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[403]
|
HTTP status code |
GatewayTimeoutError
Bases: ServerError
HTTP 504 - Timeout from the gateway after failing to route request to destination service.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[504]
|
HTTP status code |
HTTPRateLimitError
Bases: HTTPClientError
HTTP 429 - Client request exceeds rate limits.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[429]
|
HTTP status code |
NotAuthorizedError
Bases: HTTPClientError
HTTP 401- Not authorized.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[401]
|
HTTP status code |
NotFoundError
Bases: HTTPClientError
HTTP 404 - Resource not found.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[404]
|
HTTP status code |
TimeoutError
Bases: HTTPClientError
HTTP 408 - Request Timeout.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[408]
|
HTTP status code |
RateLimitError
Bases: OpenAQError
Exception for catching rate limit exceedances from client.
ServerError
Bases: APIError
HTTP 500 - Server or service failure.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
int
|
HTTP status code |
ServiceUnavailableError
Bases: ServerError
HTTP 503 - Indicates that the server is not ready to handle the request.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[503]
|
HTTP status code |
ValidationError
Bases: HTTPClientError
HTTP 422 - Client request with invalid parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
Literal[422]
|
HTTP status code |