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-apiFor 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:
Built-in HTTP/HTTPS Server
Example:const { createServer } = require('crypto-bot-api'); const server = createServer(webhookHandler); server.listen(3000);- Express Middleware
Integrate seamlessly with Express.js or similar frameworks.
π Explore webhook examples.
Documentation & Resources
- π Full API Documentation
- π‘ Usage Examples
- π Changelog
- π€ Official CryptoBot API Docs
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
- ESLint enforced for consistency.
- PRs must pass linting and include updated documentation.
Compatibility
- Node.js: v12+
- Browsers: Chrome 32+, Firefox 29+, Edge 12+, Safari 8+
- Mobile: iOS 8+, Android 4.4.4+
License
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.