Crypto Bot API Client Library for Telegram's Crypto Pay API

Β·

Overview

A modern TypeScript client library designed for seamless integration with Telegram's Crypto Pay API via CryptoBot. This library simplifies cryptocurrency transactions, webhooks handling, and API interactions while ensuring type safety and up-to-date compatibility.


Installation

Via npm or yarn

npm install crypto-bot-api
# OR
yarn add crypto-bot-api

For browser-based projects, include bundles from the dist directory or add the package to your dependencies.


Usage Examples

Node.js Implementation

const CryptoBotAPI = require('crypto-bot-api');
const client = new CryptoBotAPI('YOUR_API_TOKEN');
const botInfo = await client.getMe();
console.log(botInfo);

Browser Implementation

<script src="path/to/crypto-bot-api-browser.js"></script>
<script>
  var client = new CryptoBotAPI('YOUR_API_TOKEN');
  client.getMe().then(function(response) {
    console.log(response);
  });
</script>

πŸ‘‰ Note: As of March 2025, API servers lack CORS headers, limiting browser-based requests. Use in extensions, Electron, or similar environments.


Webhooks Handling

Crypto Pay API supports event-driven updates via webhooks. The library offers two approaches:

  1. Built-in HTTP/HTTPS Server
    Example:

    const { createServer } = require('crypto-bot-api');
    const server = createServer(webhookHandler);
    server.listen(3000);
  2. Express Middleware
    Integrate seamlessly with Express.js or similar frameworks.

πŸ‘‰ Explore webhook examples.


Documentation & Resources


Development & Contribution

Build Commands

npm run build-docs  # Generate documentation
npm run build-lib   # Node.js build
npm run build-dist  # Browser bundles
npm run watch       # Development mode (live reload)

Code Standards


Compatibility


License

MIT


FAQs

1. Why can't I use this library directly in a browser?

API servers block cross-origin requests. Use Electron or browser extensions instead.

2. How do I enable webhooks?

Configure webhooks in CryptoBot settings and provide a valid SSL certificate.

3. Can I use self-signed certificates?

Yes, but upload the certificate via CryptoBot’s API settings.

4. Is TypeScript support included?

Yes! The library is written in TypeScript with full type definitions.

πŸ‘‰ Need more help? Check advanced configurations here.