Python
The official Python client for the Bias API. It is fully type-hinted, ships with both synchronous and asynchronous clients, and is generated from the Bias OpenAPI specification.
Installation
Requires Python 3.9 or later.
Usage
Construct a client with your API key and call resource methods directly. Models are returned as fully typed objects.
If you omit api_key, the client reads it from the BIAS_API_KEY environment variable.
Pagination
List methods return a page object. Iterate a single page, or use auto_paging_iter() to walk every page transparently — the SDK fetches subsequent pages for you using the cursor.
A page exposes data (the items on that page) and has_more (whether more pages exist).
Expanding related objects
Pass expand to inline related objects instead of receiving bare IDs. See expansion for the full list of expandable fields.
Streaming events
The events resource can return a long-lived stream of events instead of a single page. Iterate it to process events as they arrive.
The async client exposes the same method as an async iterator:
See the event streaming guide for more.
Error handling
Non-2xx responses raise typed exceptions. Every SDK exception derives from biaspay.BiasError, so you can catch broadly or narrow to a specific error type.
The full exception hierarchy:
| Exception | Raised when |
|---|---|
BiasError | Base class for all SDK exceptions. |
APIError | The API returned an error response. |
InvalidRequestError | The request was malformed or failed validation (400/422). |
AuthenticationError | The API key is missing or invalid (401). |
PaymentError | A payment was declined or could not be processed. |
IdempotencyError | An idempotency key was reused with a different request. |
RateLimitError | Too many requests (429). |
ServerError | The API returned a 5xx response. |
APIConnectionError | The request could not reach the API. |
APITimeoutError | The request timed out. |
Async
AsyncBias mirrors Bias exactly, with awaited methods. Use it as an async context manager so the underlying HTTP client is closed cleanly.
Configuration
To reuse connection pools or customize transport, inject your own httpx.Client (or httpx.AsyncClient for AsyncBias):