The Blnk TypeScript SDK is the official Node.js client for Blnk Core, published as @blnkfinance/blnk-typescript .
For detailed documentation on each API, reference the Core documentation .
Quick start
In a few minutes, you’ll have a Node.js app moving money on your Blnk ledger. That’s the starting point for wallets, transfers, and the rest of your product.
Launch Blnk
You need a running Blnk Core instance before using the SDK.
Install Blnk Local install or Blnk Cloud
Install the TypeScript SDK
Create a Node.js project and install the SDK. You need Node.js 18 or later . npm init -y
npm install @blnkfinance/blnk-typescript
npm install -D tsx typescript
Client initialization
Call BlnkInit to create a client. Pass your API key as the first argument when your instance requires authentication. The SDK sends it as the X-Blnk-Key header. Use an empty string when running locally without auth. BlnkInit is synchronous: do not await it. import { BlnkInit } from '@blnkfinance/blnk-typescript' ;
const apiKey = process . env . BLNK_API_KEY ?? '' ;
const blnk = BlnkInit ( apiKey , {
baseUrl: 'http://localhost:5001' ,
timeout: 10000 ,
});
Create your first transaction
Create index.ts, paste the script below, and run it: import { BlnkInit } from '@blnkfinance/blnk-typescript' ;
const blnk = BlnkInit ( '' , { baseUrl: 'http://localhost:5001' });
const response = await blnk . Transactions . create ({
amount: 1000 ,
reference: 'first_txn_001' ,
currency: 'USD' ,
precision: 100 ,
source: '@FundingPool' ,
destination: '@MyBalance' ,
description: 'My first Blnk transaction' ,
allow_overdraft: true ,
});
if ( response . status !== 201 || ! response . data ) {
console . error ( `Error ${ response . status } : ${ response . message } ` );
process . exit ( 1 );
}
console . log ( 'Transaction ID:' , response . data . transaction_id );
console . log ( 'Status:' , response . data . status );
See all 22 lines
Run the script: Your script prints the transaction ID when it succeeds. Verify the record with the CLI or in Blnk Cloud. Internal balances like @FundingPool are created automatically. See Internal balances to learn how they work.
Error handling
Every SDK method returns an ApiResponse<T> envelope:
interface ApiResponse < T > {
status : number ;
message : string ;
data : T ;
}
Check status and data after every call:
const response = await blnk . Ledgers . create ({
name: 'Customer accounts' ,
});
if ( response . status !== 201 || ! response . data ) {
console . error ( `Error ${ response . status } : ${ response . message } ` );
return ;
}
console . log ( 'Ledger ID:' , response . data . ledger_id );
The SDK handles three failure modes:
HTTP errors : Non-2xx responses return the status code, a message, and the error body in data.
Client-side validation : SDK validators return status: 400 with a message before the network call (for example, a missing reference or an invalid bulk payload).
Network or timeout errors : Caught internally and returned as a failed ApiResponse with a logged error.
Using the SDK
Reference the Core documentation to understand how each API works. This section shows how those APIs are organized in the TypeScript SDK.
Client structure
BlnkInit returns a client with one service per resource:
blnk.Ledgers
blnk.LedgerBalances
blnk.Transactions
blnk.BalanceMonitor
blnk.Reconciliation
blnk.Search
blnk.Identity
Call methods on the service that matches the resource you need. The endpoint map lists each method and links to its API reference page.
Request field names
Use snake_case field names that match the HTTP API directly: meta_data, ledger_id, allow_overdraft, and so on.
await blnk . Transactions . create ({
amount: 1000 ,
precision: 100 ,
currency: 'USD' ,
source: 'bln_28f25ef6-2e0d-4fa6-891c-37fc409d654e' ,
destination: 'bln_86ba7976-499d-4282-955e-a7c2abf5db12' ,
reference: 'payment_001' ,
allow_overdraft: true ,
meta_data: { tier: 'gold' },
});
Client options
Pass options as the second argument to BlnkInit:
baseUrl: Required. A trailing / is appended automatically if missing.
timeout: HTTP timeout in milliseconds. Defaults to 3000.
const blnk = BlnkInit ( process . env . BLNK_API_KEY ?? '' , {
baseUrl: 'http://localhost:5001' ,
timeout: 30000 ,
});
Use ESM import syntax in TypeScript projects:
import { BlnkInit } from '@blnkfinance/blnk-typescript' ;
CommonJS also works and matches the GitHub examples :
const { BlnkInit } = require ( '@blnkfinance/blnk-typescript' );
Endpoint map
Each SDK method calls a Blnk Core HTTP endpoint. Use this map to find the SDK method for an operation and open its reference page for field definitions and business logic.
Read the linked Core reference page for each method to understand required fields, validation rules, and behavior.
Ledgers
Balances
Transactions
Reconciliation
Identities
Typesense Search
Monitors
SDK method API Reference blnk.Ledgers.createCreate ledger blnk.Ledgers.getGet ledger
const response = await blnk . Ledgers . create ({
name: 'Customer accounts' ,
meta_data: { project_owner: 'MyApp' },
});
SDK method API Reference blnk.LedgerBalances.createCreate balance blnk.LedgerBalances.getGet balance
const response = await blnk . LedgerBalances . create ({
ledger_id: 'ldg_049495c6-356e-4ebc-a45e-60d1e1e16afb' ,
currency: 'USD' ,
});
SDK method API Reference blnk.Transactions.createCreate transaction blnk.Transactions.createBulkBulk transactions blnk.Transactions.updateStatusUpdate inflight blnk.Transactions.refundRefund transaction
For bulk transaction concepts and options, see the Bulk transactions guide . Create
CreateBulk
UpdateStatus
Refund
const response = await blnk . Transactions . create ({
amount: 1000 ,
precision: 100 ,
currency: 'USD' ,
source: '@FundingPool' ,
destination: '@MyBalance' ,
reference: 'payment_001' ,
allow_overdraft: true ,
});
SDK method API Reference blnk.Reconciliation.uploadUpload data blnk.Reconciliation.createMatchingRuleCreate matching rule blnk.Reconciliation.runStart reconciliation
Upload
CreateMatchingRule
Run
const response = await blnk . Reconciliation . upload (
'statement.csv' ,
'stripe' ,
);
SDK method API Reference blnk.Identity.createCreate identity blnk.Identity.getGet identity blnk.Identity.listGet identity blnk.Identity.updateEdit identity
const response = await blnk . Identity . create ({
identity_type: 'individual' ,
first_name: 'Jane' ,
last_name: 'Doe' ,
gender: 'female' ,
nationality: 'US' ,
dob: new Date ( '1990-01-15' ),
email_address: 'jane@example.com' ,
phone_number: '+1234567890' ,
category: 'customer' ,
street: '123 Main St' ,
city: 'New York' ,
state: 'NY' ,
country: 'USA' ,
post_code: '10001' ,
});
See all 16 lines
Use Search.search for full-text search powered by Typesense. SDK method API Reference blnk.Search.search(params, collection)Search via Typesense
Pass a collection name as the second argument: 'ledgers', 'transactions', or 'balances'. Transactions
Balances
Ledgers
const response = await blnk . Search . search (
{ q: 'payment' , per_page: 20 },
'transactions' ,
);
For structured DB queries without Typesense, use the Search via DB HTTP API directly. SDK method API Reference blnk.BalanceMonitor.createCreate balance monitor blnk.BalanceMonitor.getGet balance monitor blnk.BalanceMonitor.listGet balance monitor blnk.BalanceMonitor.updateEdit balance monitor
const response = await blnk . BalanceMonitor . create ({
balance_id: 'bln_5ce86029-3c2e-4e2a-aae2-7fb931ca4c4f' ,
condition: {
field: 'credit_balance' ,
operator: '>' ,
value: 1000 ,
precision: 100 ,
},
});
Where to find examples
TypeScript SDK examples Escrow, savings, cards, and reconciliation.
Core tutorials Step-by-step use case guides
Ledgers Group and organize balances
Balances Wallets, accounts, and stores of value
Need help?
We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool.
To ask questions or discuss issues, please contact us or join our Discord community .
Issue reporting and contributions
The TypeScript SDK is open-source on GitHub , and we welcome community issues and pull requests.
If you run into problems installing or using the SDK, report them on GitHub .
If an endpoint is documented in the API reference but missing from the TypeScript SDK, we encourage opening an issue or submitting a pull request to help improve SDK coverage.