Exceptions Reference
Exception classes for error handling.
exceptions
Custom exceptions for the revolut-x-python library.
Exception hierarchy::
RevolutXError (base)
├── AuthenticationError — missing/invalid API key or private key
├── RateLimitError — HTTP 429, retry after N seconds
├── ApiError — any non-2xx API response
├── OrderValidationError — payload violates exchange rules
└── NetworkError — connection timeout, DNS failure, etc.
All exceptions inherit from :class:RevolutXError, so you can catch them all
with a single except RevolutXError block, or handle each type individually.
ApiError
ApiError(message: str, *, status_code: int, response_body: Any = None, endpoint: str = '', method: str = '')
Bases: RevolutXError
Raised when the Revolut X API returns a non-2xx HTTP status code.
This covers client errors (4xx) and server errors (5xx) that are not authentication (401/403) or rate-limit (429) related.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
The HTTP status code returned by the API (e.g. 400, 404, 500). |
|
response_body |
The parsed JSON response body, or raw text if parsing failed. |
|
endpoint |
The API endpoint that was called (e.g. |
|
method |
The HTTP method used (e.g. |
Source code in src/revolut_x/exceptions.py
AuthenticationError
Bases: RevolutXError
Raised when authentication is missing, misconfigured, or rejected.
Common causes:
api_keywas not provided when creating :class:RevolutXClient.- The private key file does not exist or has an invalid format.
- The API returned HTTP 401 or 403 (expired key, wrong signature, …).
Attributes:
| Name | Type | Description |
|---|---|---|
hint |
A human-readable suggestion on how to fix the problem. |
Source code in src/revolut_x/exceptions.py
NetworkError
Bases: RevolutXError
Raised when a network-level error prevents the request from completing.
This wraps connection timeouts, DNS resolution failures, refused connections, and other transport-layer errors.
Attributes:
| Name | Type | Description |
|---|---|---|
original_error |
The underlying :class: |
Source code in src/revolut_x/exceptions.py
OrderValidationError
Bases: RevolutXError, ValueError
Raised when an order payload violates exchange rules before submission.
This is a client-side validation — the order is not sent to the exchange. Fix the payload and try again.
Attributes:
| Name | Type | Description |
|---|---|---|
errors |
A list of human-readable strings describing each violated rule. |
Example::
try:
client.place_market_order("BTC-EUR", OrderSide.BUY, quote_size="0.01")
except OrderValidationError as exc:
for err in exc.errors:
print(f" - {err}")
Source code in src/revolut_x/exceptions.py
RateLimitError
RateLimitError(message: str, *, retry_after_seconds: float | None = None, endpoint: str | None = None)
Bases: RevolutXError
Raised when the Revolut X API returns HTTP 429 (Too Many Requests).
The library retries automatically up to max_retries times. This
exception is raised only when all retries have been exhausted.
Attributes:
| Name | Type | Description |
|---|---|---|
retry_after_seconds |
Suggested wait time (from the |
|
endpoint |
The API endpoint that triggered the rate limit. |
Source code in src/revolut_x/exceptions.py
RevolutXError
Bases: Exception
Base exception for all errors raised by the revolut-x-python library.
You can catch this to handle any library error generically::
try:
client.get_ticker("BTC-EUR")
except RevolutXError as exc:
logging.error("Revolut X error: %s", exc)