A Python-based Telegram bot for fetching real-time cryptocurrency prices from CoinGecko. Provides price data, historical charts, market cap rankings, and Ethereum gas prices.
Live bot: @h_crypto_price_bot
For advanced features like rate limits and usage tracking, check out the hcpb-api repository (work in progress).
-
Make sure you have Python 3.13 installed:
python --version
-
Clone the repository:
git clone https://github.com/halon176/h-crypto-price-bot.git cd h-crypto-price-bot -
Install dependencies using uv:
uv sync
-
Create a Telegram bot via BotFather and copy the token.
-
Set up environment variables:
export TELEGRAM_TOKEN=<your_telegram_bot_token> export ETHSCAN_API_KEY=<your_etherscan_api_key> # Required for gas prices export CMC_API_KEY=<your_coinmarketcap_api_key> # Optional export LOGFIRE_TOKEN=<your_logfire_token> # Optional, enables telemetry in Logfire export API_URL=<api_url> # Optional
With
LOGFIRE_TOKENconfigured, the bot exports logs, traces and these metrics:bot.handler.calls_totalbot.handler.errors_totalbot.handler.duration_secondsbot.chart.generation.totalbot.chart.generation.errors_totalbot.chart.generation.duration_seconds
-
Run the bot:
uv run python src/main.py
-
Clone the repository:
git clone https://github.com/halon176/h-crypto-price-bot.git
-
Build the Docker image:
docker build -t h-crypto-price h-crypto-price-bot/.
-
Run the container:
# Basic setup docker run -d \ -e TELEGRAM_TOKEN=<your_telegram_bot_token> \ --name h-crypto-price \ h-crypto-price # With optional API keys docker run -d \ -e TELEGRAM_TOKEN=<your_telegram_bot_token> \ -e ETHSCAN_API_KEY=<your_etherscan_api_key> \ -e CMC_API_KEY=<your_coinmarketcap_api_key> \ --name h-crypto-price \ h-crypto-price
Get cryptocurrency prices using /p followed by the symbol:
/p btc
/p eth
/p sol
Type /help for a full list of available commands.
Contributions are welcome! If you have any suggestions or bug reports, please open an issue on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.