npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

account-pay

v0.2.0

Published

Unofficial Khan Bank (e.khanbank.com) client: login, account transactions, IBAN generation and account holder lookup

Readme

account-pay

Unofficial Node.js client for Khan Bank e-banking (e.khanbank.com). Log in with your e-banking credentials, list account transactions, build Mongolian IBANs offline, and look up account holders at any Mongolian bank.

This library talks to the same private API the e-banking web app uses. It is not endorsed by Khan Bank and may break whenever the bank changes its API. Use it only with your own account.

Install

npm install account-pay

Requires Node.js 16 or newer. TypeScript types are included.

Quick start

import AccountPay from "account-pay";

await AccountPay.Auth({
  DEVICE_ID: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "device-id" header from browser dev tools
  ACCOUNT: 5400012345,                              // your Khan Bank account number
  USER: "login.name",                               // e-banking login
  PASSWORD: "********",                             // e-banking password
  USERNAME: "OWNER NAME",                           // account owner as shown in e-banking
});

// Transactions for the last 2 days
const rows = await AccountPay.listTransaction(2);

// Account holder at another bank (Golomt, bankRefNo "203")
const holder = await AccountPay.transaction.retrieve("1605157029", "203");
// { fullName: "...", iban: "MN070015001605157029", account: "1605157029", name: "...", msgId: "..." }

Keep credentials in environment variables or a secrets store. Never commit them.

API

Auth(options): Promise<string>

Stores the credentials and fetches an access token. Resolves to "Success Login khaanbank" or "Failed Login khaanbank"; it does not throw on a bad login, so check the returned string.

| Option | Type | Description | | --- | --- | --- | | DEVICE_ID | string | Value of the device-id request header. Log in once at e.khanbank.com in a browser and copy it from the network tab. | | ACCOUNT | number | Account number whose transactions you want to read. | | USER | string | E-banking login name. | | PASSWORD | string | E-banking password (sent base64-encoded, as the web app does). | | USERNAME | string | Account owner name. |

The token expires after about 5 minutes. Every other call refreshes it automatically on a 401.

listTransaction(days): Promise<Transaction[]>

Raw transactions for ACCOUNT from days days ago until today. See Transaction in dist/types.d.ts for the shape.

listNewTransaction(days): Promise<PushData[]>

Same data flattened into a simpler row:

{
  date: "2024-08-09 04:18:00",
  accountNumber: "5400012345",
  transactionType: "Credit" | "Debit",
  expenseBalance: 0,
  incomeBalance: 990,
  beginBalance: 0,
  endBalance: 990,
  description: "SETTLEMENT - SELLER PANDA",
  txnBranchId: "5008",
  id: "17231932800990"      // timestamp + endBalance
}

transaction.retrieve(accountId, bankCode): Promise<AccountInquiry>

Look up an account holder. bankCode can be any of:

  • a bankRefNo from BankOfList() (for example "203" for Golomt)
  • a 6-digit clearing code ("150000")
  • a 4-digit IBAN bank code ("0015")

The IBAN is built locally and sent to the bank's inquiry endpoint. Rejects with the bank's { code, message } (for example CA0008 for a malformed IBAN) or with Unknown bank code if the code is not in the list.

transaction.retrieveByIban(iban): Promise<AccountInquiry>

Same lookup when you already have the IBAN.

interface AccountInquiry {
  fullName: string;
  iban: string;
  account: string;
  msgId: string;
  name: string;
}

transaction.generateIban(bankClearingCode, account): string

Builds a Mongolian IBAN offline: MN + 2 check digits + 4-digit bank code + account zero-padded to 12 digits. Accepts a 6-digit clearing code or a 4-digit bank code. This only computes the checksum and does not verify that the account exists.

AccountPay.transaction.generateIban("150000", "1605157029"); // "MN070015001605157029"
AccountPay.transaction.generateIban("040000", 5400038909);   // "MN720004005400038909"

transaction.resolveBankClearingCode(bankCode): Promise<string>

Resolves a bankRefNo, clearing code, or IBAN bank code to the 6-digit clearing code.

transaction.BankOfList(): Promise<Bank[]>

Static list of banks known to Khan Bank's transfer form, with bankName, bankClearingCode, bankRefNo, and network type (RTG, ACH, SWI).

Development

npm install
npm run build-ts   # compile to dist/
npm test           # runs test/index.ts with ts-node; set KHAN_* env vars first

npm publish runs the build automatically via prepublishOnly.

License

ISC