Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

crypto-bot-api

sergeiivankov882MIT0.3.5TypeScript support: included

Simple and minimalistic client for Telegram CryptoBot Crypto Pay API

crypto-bot-api, crypto-bot, crypto-pay-api, crypto-pay, api-client, crypto, cryptocurrency, exchage, payment-processing, cryptocurrency-processing, ton, the-open-network, telegram-bot

readme

Crypto Bot API - client library for Crypto Pay API

Written in TypeScript up-to-date client library for Crypto Pay API provided by Telegram CryptoBot.

Installing

Using npm/yarn:

$ npm install crypto-bot-api
$ yarn add crypto-bot-api

For browsers use bundles from dist directory or add package to your project dependencies and import it.

Usage

In Node.js:

const CryptoBotAPI = require('crypto-bot-api');

const client = new CryptoBotAPI('1234:AAA...AAA');

const me = await client.getMe();
console.log(me);

In browsers:

<script src="crypto-bot-api.min.js"></script>
<script>
  var client = new CryptoBotAPI('1234:AAA...AAA');

  client.getMe().then(function(me) {
    console.log(me);
  });
</script>

Important: at the time of publication of version 0.3.5 (Mar 24, 2025), API servers do not return header Access-Control-Allow-Origin, which allows make requests to API from third-party domains, so client request from website environment won't work (but its work in browser extensions, Electron and similar apps)

More usage examples see in examples project directory.

Receiving updates

Crypto Pay API support events by sending webhooks requests. To handle webhooks request library proposes to use creating Node.js built-in HTTP or HTTPS server or using Express.js-like middleware API. See examples with names starts with webhooks-.

Note: you need enable webhooks in CryptoBot app settings, if you want to use self-signed certificate you must uploat it in CryptoBot API application settings

Documentation

Library documentation can be found in repository GitHub page.

For Node.js usage, we advise you to start studying documentation with library default exported ClientEmitter class.

For browsers usage, we advise you to start studying documentation with library default exported for browsers Client class.

Building

Files for Node.js compiled to lib directory. Browsers bundles compiled to dist directory.

$ git clone https://github.com/sergeiivankov/crypto-bot-api
$ cd crypto-bot-api
$ npm i
$ npm run build-docs # To build library documentation
$ npm run build-lib # To build for Node.js
$ npm run build-dist # To build for Browsers
$ npm run build # To build all

Also, project have watch commands to using it in development:

$ npm run watch-docs # To watch build library documentation
$ npm run watch-lib # To watch build for Node.js
$ npm run watch-dist # To watch build for Browsers
$ npm run watch # To watch all

Resources

Code quality

To maintain high quality of the code and bring source code to a consistent form, project use eslint linter and has high documentation requirements. If you want to make a pull request, check that documentation matches your changes and eslint does not signal errors with command:

$ npm run lint

Supported environments

  • >= Node.js 12
  • >= Chrome 32
  • >= Firefox 29
  • >= Edge 12
  • >= Safari 8
  • >= Safari on iOS 8
  • > Android Browser 4.4.4

License

MIT

changelog

Changelog

0.3.5 - 2025-03-24

  • Add new support MEMHASH currency code to types
  • Fix paid event arguments optional status
  • Fix http create server field required status
  • Update dependencies, fix build config
  • Add TypeScript examples, fix examples errors

0.3.4 - 2025-01-30

  • Add new support currencies codes to types

Thanks:

0.3.3 - 2024-09-18

  • Fix default export type

0.3.2 - 2024-09-17

  • Fix export types
  • Readme fixes

0.3.1 - 2024-09-17

  • Added ability to create HTTP server, not only HTTPS
  • Change empty request body error response code to 401
  • Readme fixes
  • Update dependencies

Thanks:

0.3.0 - 2024-09-16

  • Add getStats, createCheck, getChecks, getChecksPaginate, transfer, getTransfers, getTransfersPaginate, deleteInvoice and deleteCheck methods
  • Change methods getInvoices and getInvoicesPaginate to returns array of Invoice
  • Remove currency field from GetInvoicesOptions and GetInvoicesPaginateOptions types and add asset and fiat fields
  • Update Invoice type to actual API version
  • Update createInvoice method to actual API version, change related options types
  • Change return type of getExchangeRate method and field rate of ExchangeRate type which returned by getExchangeRates method to string
  • Change Invoice type amount field type to string
  • Change getInvoices options ids field type to number[]
  • Fix getInvoices backend method invoice_ids parameter type
  • Remove calculating and returning exchange rate for reverse pair of source and target by getExchangeRate method
  • Add isValid field to ExchangeRate type
  • Change getExchangeRate method to return '0' value for non-valid exchange rate
  • Change Balances type to store available and on hold balances in new Balance type
  • Create BalancesType type to store available or on hold balances
  • Remove isReturnInNanos and isForce parameters from getBalances and getBalance methods
  • Add getBalancesAvailable, getBalancesOnhold, getBalanceAvailable and getBalanceOnhold to get balances by type
  • Create CurrencyCode type with known variants
  • Add code field to Currency type
  • Add unknown variant for CurrencyType
  • Replace CurrencyType by enum and store it in Client class
  • Rename CurrencyType to DetailedCurrencyType with more detailed variants
  • Use CurrencyType type to main types variants and store it in Client class
  • Replace InvoiceStatus by enum and store it in Client class
  • Fix library connection in examples
  • Fix links in readme.md
  • Fix Client class setPageSize method documentation parameter name
  • Fix ClientEmitter.constructor documentation inheritance
  • Update dependencies

0.2.1 - 2024-04-23

  • Fix getInvoices identifiers parameter name

Thanks:

0.2.0 - 2021-12-09

  • Using mainnet endpoint for default

0.1.1 - 2021-12-05

  • Webhooks request data and check signature changes

0.1.0 - 2021-12-04

  • Change backend API authorization process
  • Remove methods, structures and fields related with deleted from backend API methods
  • Add webhooks receiving in Node.js with Express.js like middleware support
  • Increase Client.createInvoice payload field max size
  • Add support any type in createInvoice payload and correct parsing in getInvoices response by JSON
  • Add direct backend API call method

0.0.2 - 2021-11-30

  • Increase package version to publish on prereserved npm package name

0.0.1 - 2021-11-29

  • Initial release