Configurable client options v1.2.0 or later. 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.ts
create-ledger.ts
Authentication
BlnkInit takes two arguments: an API key and a client options object.
The options object must include baseUrl, 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 baseUrl 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 safely handles it without blocking your app. To configure, pass the following parameters in the secondoptions object:
When to tune these:
- 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
retryCountif you’re reading data across an unreliable network
Custom logger
By default, the SDK logs its internal events through a built-in logger that writes to console withINFO:, ERROR:, and DEBUG: prefixes.
Pass a custom logger to route these messages to your own logging system instead of console.
Metadata passed to the logger is redacted. The SDK strips values for keys such as
api_key, authorization, token, and secret before logging.Example logs