A Telegram bot that monitors cryptocurrency prices and sends real-time alerts
A Telegram bot that monitors cryptocurrency prices in real time via the Binance API and sends customized alerts when prices hit the thresholds set by the user. Built with python-telegram-bot on a fully asynchronous architecture.
⚠️ Unofficial project — not affiliated with Telegram or Binance. It independently uses Binance's public API and Telegram's bot API.
- ✅ Real-time price lookup for any crypto pair (BTC/USDT, ETH/USDT, etc.)
- ✅ Above/below price alerts with a user-defined value
- ✅ List of active alerts per user
- ✅ Asynchronous background monitoring
- ✅ SQLite persistence — alerts survive restarts
- ✅ Automatic rate limiting respecting Binance API limits
- python-telegram-bot — Official framework for Telegram bots
- aiohttp — Asynchronous HTTP client for the Binance API
- SQLAlchemy — ORM for alert persistence
- asyncio — Native asynchronous programming
- APScheduler — Scheduling of periodic monitoring jobs
telegram-crypto-alert-bot/
├── bot/
│ ├── main.py # Entry point
│ ├── handlers.py # Command handlers
│ ├── binance_client.py # Binance API client
│ ├── database.py # Alert persistence
│ └── monitor.py # Background monitoring job
├── tests/
├── .github/workflows/ci.yml
├── requirements.txt
├── requirements-dev.txt
├── .env.example
└── README.md
pip install -r requirements-dev.txt
ruff check . && ruff format --check .
pytest -vTests mock the Binance API and Telegram objects and run against an isolated in-memory SQLite database. The same checks run on every push and pull request via GitHub Actions.
- Python 3.11+
- Telegram bot token — create one via @BotFather
git clone https://github.com/LacerdaTraderCode/telegram-crypto-alert-bot.git
cd telegram-crypto-alert-bot
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
pip install -r requirements.txt
cp .env.example .env
# Edit .env and add your TELEGRAM_BOT_TOKEN
python -m bot.main| Command | Description | Example |
|---|---|---|
/start |
Welcome message | /start |
/help |
Lists all commands | /help |
/price <pair> |
Current price of the pair | /price BTCUSDT |
/alert <pair> <above|below> <value> |
Creates an alert | /alert BTCUSDT above 70000 |
/alerts |
Lists active alerts | /alerts |
/remove <id> |
Removes an alert by ID | /remove 3 |
User: /price BTCUSDT
Bot: 💰 BTCUSDT: $67,432.50 (+2.15% in 24h)
User: /alert BTCUSDT above 70000
Bot: ✅ Alert created! I'll notify you when BTCUSDT passes $70,000
[when the price rises...]
Bot: 🚨 ALERT! BTCUSDT reached $70,150 — your target was $70,000
- ✅ Bot token is never committed (kept in
.env) - ✅ Each user only sees their own alerts
- ✅ Rate limiting prevents Binance API abuse
- ✅ Error handling on all asynchronous operations
- VPS — DigitalOcean, Linode, Contabo
- Railway or Render — free tier available
- Raspberry Pi — ideal for personal use
- Python 3.11 or higher
- Telegram bot token
Wagner Lacerda — Senior Software Engineer | Python, Backend, AI Apps, Automation & Systems
📍 Rio Grande do Sul, Brazil
Distributed under the MIT license. See LICENSE for more details.