Telegram bot for getting live cryptocurrency prices from CoinMarketCap.
npm install
cp .env.example .envEdit .env with your credentials:
TELEGRAM_BOT_TOKEN— Get from @BotFatherCMC_API_KEY— Get from coinmarketcap.com/api
Start the bot:
npm startRun tests:
npm testIn Telegram, the slash command menu (descriptions for /start, /help, /price) is set automatically on startup. While a /price request is fetching data from CoinMarketCap, the bot may show a typing indicator. Very long answers are split across up to three messages so they stay within Telegram’s per-message length limit.
/help
Response shows all available commands and examples.
/price BTC
Response:
1 BTC = $67000.00 USD (Bitcoin)
📈 24h: +2.5%
/price 0.5 SOL
Response:
0.5 SOL = $42.00 USD (Solana)
📈 24h: +1.2%
/price solana
Response:
1 SOL = $84.00 USD (Solana)
📈 24h: +1.2%
/price 1 BTC -idr
Response:
1 BTC = $67000.00 USD (Bitcoin)
1 BTC = Rp 1072000000.00 IDR (Bitcoin)
📈 24h: +2.5%
/price 0.5 BTC -idr,eur
/price solana eth -usd
When a symbol matches multiple tokens, the bot shows ranked options:
🔍 Top matches for "pros":
PROS (Prosper)
30 PROS = $0.0197 USD
📈 24h: +0.51%
Rank: #1912
━━━━━━━━━━━━━━━━━━━━
PROS (Pharos)
30 PROS = $0.7573 USD
📈 24h: +0.51%
Rank: #3723
━━━━━━━━━━━━━━━━━━━━
/start sends a short welcome, then the same command help text as /help (format, flags, and examples).
- Bot: 10 requests per minute per user (configurable via env)
- CMC API: varies by plan
| Variable | Default | Description |
|---|---|---|
RATE_LIMIT |
10 | Max requests per user per window |
RATE_WINDOW_SEC |
60 | Rate limit window in seconds |
LOG_LEVEL |
INFO | ERROR / WARN / INFO / DEBUG |
TELEGRAM_BOT_TOKEN |
— | Telegram bot token (required) |
CMC_API_KEY |
— | CoinMarketCap API key (required) |
Set via LOG_LEVEL env var (default: INFO):
ERROR— Only errorsWARN— Errors + warningsINFO— Errors, warnings, and startup/shutdown eventsDEBUG— Everything including slow request traces
Logs written to logs/bot.log with 5MB rotation.
/price <amount> <symbol> [-target_currency1,target_currency2]
| Parameter | Description |
|---|---|
amount |
Number of crypto units (default: 1) |
symbol |
Ticker (BTC, ETH) or name (bitcoin, solana) |
-idr |
Convert to Indonesian Rupiah |
-eur |
Convert to Euro |
-gbp |
Convert to British Pound |
-jpy |
Convert to Japanese Yen |
-eth |
Convert to Ethereum |
-btc |
Convert to Bitcoin |
-usd |
Explicitly request USD (default) |
/price btc → 1 BTC = $67000 USD
/price 0.5 sol → 0.5 SOL = $42 USD
/price solana -idr → 1 SOL = $84 USD + IDR
/price bitcoin -eth → 1 BTC = USD + ETH