Exceptions
oilpriceapi.exceptions
Typed OilPriceAPI errors and compatibility parsing for API responses.
OilPriceAPIError
Bases: Exception
Stable base contract for API, transport, and configuration errors.
BadRequestError
AuthenticationError
PaymentRequiredError
PermissionDeniedError
RateLimitError
Bases: OilPriceAPIError
Raised when API rate limit is exceeded (HTTP 429).
seconds_until_reset
property
Calculate seconds until rate limit resets.
DataNotFoundError
ValidationError
FuturesContractError
Bases: ValidationError, ValueError
Raised when a futures contract or slug cannot be resolved (#122).
Two base classes, deliberately:
ValidationError-- soexcept OilPriceAPIErrorcatches it. Every documented recovery path in this SDK is written against that base class, and #111 turned 18 live catalog codes from "resolved to a DIFFERENT instrument" into "raises". A refusal is only recoverable if it is catchable, and a bare builtinValueErrorwas not.ValueError-- so code written against the pre-#111raise ValueErrorkeeps working. This is not a breaking change.
SubscriptionIntervalError
Bases: ValidationError, ValueError
Raised locally when a subscription interval cannot be parsed (#100).
Two base classes, deliberately:
ValidationError-- soexcept OilPriceAPIErrorcatches it, like every other refusal in this SDK. It is raised before any request is built, sostatus_codeisNone,fieldis"interval"andvalueis the rejected input.ValueError-- so code written against the pre-#100raise ValueErrorfromsubscriptions.create(interval=...)andnormalize_intervalkeeps working. This is not a breaking change.
Only the interval path that already raised ValueError gets the dual
base. Refusals introduced with get/update/pause/resume and
the delete id check raise a plain ValidationError.
ServerError
NetworkError
TimeoutError
ConfigurationError
error_from_response(response, *, commodity=None)
Normalize canonical, legacy, and malformed HTTP error responses.
error_from_exception(error, *, api_key=None, timeout=None)
Normalize transport failures while redacting the configured API key.