Configurable client options ship in v1.3.0. See the Changelog before upgrading.
Initialize the client
Your Blnk client is the single entry point to everything: ledgers, balances, transactions, webhooks, and more. Configure it once when your app starts, then use it everywhere.blnk_client.py
create_ledger.py
requests.Session closed automatically:
Authentication
blnk_init takes two arguments: an API key and a BlnkClientOptions object.
The options object must include base_url, the root URL of your Blnk Core instance. The SDK sends the API key on every request in the X-Blnk-Key header.
How you set the API key depends on whether Core runs in secure mode:
- Secure mode
- Auth disabled
When
server.secure is enabled, pass your API key as the first argument. Set base_url to the URL where Core is reachable.Secure Blnk
Secure mode, master key, and server hardening.
Scoped API keys
Owner-scoped keys and permission limits.
Timeouts and retries
When connections fail, Core restarts, or requests hang, the SDK handles it without blocking your app. Pass these parameters onBlnkClientOptions:
| Option | Type | Default | What it does for you |
|---|---|---|---|
timeout | int | 10000 | Milliseconds to wait before giving up on a request. Bump this for slow operations like bulk reconciliations. |
retry_count | int | 1 | Total attempts including the first. 1 means one attempt, no retries. 3 means try up to 3 times. |
retry_delay_ms | int | 2000 | Milliseconds between retries. Uses linear backoff. |
- Keep defaults if you’re making fast, local calls and want to fail fast.
- Increase
timeoutif you’re running large batch requests that may take a while to complete synchronously. - Increase
retry_countif you’re reading data across an unreliable network.
Custom logger
By default, the SDK logs internal events through a built-in logger that writes to the console withINFO:, ERROR:, and DEBUG: prefixes.
Pass a custom logger to route these messages to your own logging system instead of the console.
Metadata passed to the logger is redacted. The SDK strips values for keys such as
api_key, authorization, token, and secret before logging.| Level | When the SDK calls it |
|---|---|
info | Before a retry, or when a retryable GET failure will be retried |
error | When a request times out, returns a non-retryable HTTP error, or fails with a network error |
Example logs
Related docs
Quick start
Install the SDK and create your first transaction.
Error handling
ApiResponse checks and Core error bodies.
Changelog
Python SDK releases and version history.