> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blnkfinance.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started with the TypeScript SDK

> Learn how to work with the Blnk SDK for TypeScript.

Welcome to the Blnk SDK for TypeScript Developer Guide. In this guide, you'll learn how to install Blnk and work with our Blnk TypeScript SDK. To view the open-source file, see the following: [Blnk TypeScript SDK](https://github.com/blnkfinance/blnk-ts/).

You'll also find examples of running different fintech use cases with our TypeScript SDK.

## Prerequisites

Ensure that you have the following installed on your machine.

1. [Docker](https://www.docker.com/) and [Compose](https://docs.docker.com/compose/) for running Blnk locally on your machine.
2. [Node.js (v14.0.0 or later)](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs) and [npm](https://www.npmjs.com/) for installing the Blnk Typescript SDK.

***

## 1: Installation & Configuration

Once you're good to go with the prerequisites, you can set up your Blnk server and SDK in 5 steps:

<Steps titleSize="h3">
  <Step title="Clone the Blnk repository">
    Run the following command in your terminal to clone Blnk to your local machine:

    ```bash bash theme={"system"}
    git clone https://github.com/blnkfinance/blnk && cd blnk
    ```
  </Step>

  <Step title="Set up your Blnk configuration">
    Create a `blnk.json` file in your `blnk` project folder, paste the following configuration settings, and save.

    ```json blnk.json theme={"system"}
    {
        "project_name": "Blnk",
        "data_source": {
            "dns": "postgres://postgres:password@postgres:5432/blnk?sslmode=disable"
        },
        "redis": {
            "dns": "redis:6379"
        },
        "server": {
            "domain": "blnk.io",
            "ssl": false,
            "ssl_email": "jerryenebeli@gmail.com",
            "port": "5001"
        },
        "notification": {
            "slack": {
            "webhook_url": "https://hooks.slack.com"
            }
        }
    }
    ```

    This configuration sets up the required connections to PostgreSQL and Redis, specifies your server details, and allows Slack notifications if needed.
  </Step>

  <Step title="Launch Blnk">
    Launch the Blnk server with the following command:

    ```bash bash theme={"system"}
    docker compose up
    ```

    Once running, your server will be accessible at [http://localhost:5001](http://localhost:5001).
  </Step>

  <Step title="Install Blnk CLI">
    The Blnk CLI helps you to quickly test and manage your Blnk backend directly from your command line. You can also use it to perform create actions or view your data tables. To install and use the Blnk CLI, see the following in: [Installing the Blnk CLI](/blnk-cli/install).

    To confirm that the CLI has been installed, run the following command:

    ```bash bash theme={"system"}
    blnk --version
    ```
  </Step>
</Steps>

***

## 2: Install the Blnk TypeScript SDK

In your `blnk` project folder, install Blnk Typescript SDK.

```bash bash theme={"system"}
npm install @blnkfinance/blnk-typescript --save
```

***

## 3: Create your first ledger

A ledger is a folder for grouping balances together in your Blnk server. To learn more, see the following: [Introduction to Ledgers](/ledgers/introduction)

To create a ledger using the TypeScript SDK:

```javascript Create ledger theme={"system"}
import { BlnkInit } from '@blnkfinance/blnk-typescript';

const blnk = await BlnkInit('<secret_key_if_set>', { baseUrl: 'http://localhost:5001' });
const { Ledgers } = blnk;

const newLedger = await Ledgers.create({
    name: "Customer Savings Account",
    meta_data: {
        project_owner: "YOUR_APP_NAME"
    }
});
console.log("Ledger Created:", newLedger);
```

You can confirm that the ledger has been created with the Blnk CLI:

```bash bash theme={"system"}
blnk ledgers list
```

***

## 4: Create your first balance

A balance is used to represent a store of value in your Blnk server, e.g., wallet or account. To learn more, see the following: [Introduction to Balances](/balances/introduction)

To create a balance using the TypeScript SDK:

```javascript Create balance theme={"system"}
const { LedgerBalances } = blnk;

const newBalance = await LedgerBalances.create({
    ledger_id: "ldg_073f7ffe-9dfd-42ce-aa50-d1dca1788adc",
    currency: "USD",
    meta_data: {
        first_name: "Alice",
        last_name: "Hart",
        account_number: "1234567890"
    }
});
console.log("Balance Created:", newBalance);
```

You can confirm that the balance has been created with the Blnk CLI:

```bash bash theme={"system"}
blnk balances list
```

***

## 5: Record your first transaction

Transaction records represent all financial activities (money in and money out) happening within your Blnk ledger. All transactions are immutable (cannot be modified or deleted) and idempotent (producing the same result no matter how many times an operation is performed).

To record a transaction using the TypeScript SDK:

```javascript Create transaction theme={"system"}
const { Transactions } = blnk;

// Create a transaction using internal balances
// Internal balances use the "@" prefix and are automatically created if they don't exist
const newTransaction = await Transactions.create({
    amount: 1000,
    reference: "first_transaction_001",
    currency: "USD",
    precision: 100,
    source: "@FundingPool",
    destination: "@MyBalance",
    description: "My first Blnk transaction",
    allow_overdraft: true,
    meta_data: {}
});
console.log("Transaction Recorded:", newTransaction);
```

You can confirm that the transaction has been created with the Blnk CLI:

```bash bash theme={"system"}
blnk transactions list
```

## 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](mailto:support@blnkfinance.com) or [join our Discord community](https://discord.gg/7WNv94zPpx).

***

<Tip>
  **Tip:** Connect to Blnk Cloud to see your Core data.

  You can view your transactions, manage identities, create custom reports, invite other team members to collaborate, and perform operations on your Core — all in one dashboard.

  [Check out Blnk Cloud →](https://www.blnkfinance.com/products/cloud)
</Tip>

## Issue reporting

If you encounter any issues while installing or using this SDK, please [report them on Github](https://github.com/blnkfinance/blnk/issues).
