Skip to main content
This guide walks you through installing the Blnk TypeScript SDK, initializing the client, and creating your first ledger resource. By the end, you’ll have a working connection to Blnk and be ready to build financial products from your TypeScript or JavaScript application.
1

Install the SDK

Install the SDK in your project. v1.2.0 and later require Node.js 18 or later.
npm install @blnkfinance/blnk-typescript
2

Create a sample script

Create an index.js file as shown below to create your first transaction with the SDK.
Make sure you have a running Blnk Core instance. Set the URL and API key as environment variables in your project.
index.js
const { BlnkInit } = require('@blnkfinance/blnk-typescript');

const blnk = BlnkInit(process.env.BLNK_API_KEY ?? '', {
  baseUrl: process.env.BLNK_BASE_URL ?? 'http://localhost:5001',
});

async function main() {
  const response = await blnk.Transactions.create({
    precise_amount: 100000,
    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) {
    throw new Error(response.message);
  }

  console.log(JSON.stringify(response.data, null, 2));
}

main();
3

Execute the script

Run the file.
node index.js
You should get the following response:
201 Created
{
  "amount": 1000,
  "rate": 0,
  "precision": 100,
  "precise_amount": 100000,
  "transaction_id": "txn_8d2ce2f0-0d75-4a91-9d43-2ad2c2e6b9ad",
  "parent_transaction": "",
  "source": "bln_f344b673-e855-4bda-b769-3e94a02c1941",
  "destination": "bln_d5cbde84-d20a-485b-8ce8-6677d782c3a1",
  "reference": "first_txn_001",
  "currency": "USD",
  "description": "My first Blnk transaction",
  "status": "QUEUED",
  "hash": "0b9c25fb5b00d6c71cb4ca87026bf6dc316e63353d3330deb588bd0b3d74dcc0",
  "allow_overdraft": true,
  "inflight": false,
  "created_at": "2024-11-26T09:33:35.265582042Z",
  "scheduled_for": "0001-01-01T00:00:00Z",
  "inflight_expiry_date": "0001-01-01T00:00:00Z",
  "inflight_commit_date": "0001-01-01T00:00:00Z"
}
4

View the transaction

Confirm the transaction landed in your ledger.
  1. Open Transactions in the sidebar.
  2. Find your transaction by reference (first_txn_001) or by the transaction_id from the script output.
  3. Click the row to open the details and verify the amount, status, source, and destination.
Blnk Cloud Transactions table with reference, amount, status, source, and destination columns
If the transaction is missing, click Refresh on the table to pull the latest data from Core.

Using the SDK

Authentication, timeouts, retries, and logging.

Error handling

ApiResponse checks and Core error bodies.

Changelog

TypeScript SDK releases and version history.

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.