Exception Hierarchy
All SDK exceptions inherit fromRulebookError. HTTP errors are further organized by
status code so you can catch exactly what you need.
Basic Error Handling
Exception Attributes
EveryAPIStatusError (and its subclasses) carries the full context of the failed request:
| Attribute | Type | Description |
|---|---|---|
message | str | Human-readable error description |
status_code | int | HTTP status code |
body | object | None | Parsed JSON response body |
response | httpx.Response | Raw HTTP response |
request | httpx.Request | The request that failed |
Catching All API Errors
Use the base classes to handle broad categories:Input Validation
The SDK validates required parameters before making HTTP calls. This raises a standardValueError, not an SDK exception:
Fee Schedule Results Error Handling
Common Error Scenarios
| Scenario | Exception | How to fix |
|---|---|---|
| Missing or invalid API key | AuthenticationError | Check your api_key or RULEBOOK_API_KEY env var |
| Exchange doesn’t exist | NotFoundError | Verify the exchange name with exchanges.list() |
| Fee schedule result not found | NotFoundError | Verify the ID with fee_schedule_results.list() |
| Version not found | NotFoundError | Check version_id from a fee schedule result |
| No access to exchange | PermissionDeniedError | Contact sales to expand your access |
| Too many requests | RateLimitError | Back off and retry, or contact sales for limits |
| Server error | InternalServerError | Retry — SDK retries automatically by default |
| Network failure | APIConnectionError | Check your internet connection |
| Request timeout | APITimeoutError | Increase timeout via client.with_options(timeout=60) |

