Skip to content

halon176/h-crypto-price-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

251 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HCryptoPrice

build tests coverage license: MIT Python 3.13

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).

Installation

Manual

  1. Make sure you have Python 3.13 installed:

    python --version
  2. Clone the repository:

    git clone https://github.com/halon176/h-crypto-price-bot.git
    cd h-crypto-price-bot
  3. Install dependencies using uv:

    uv sync
  4. Create a Telegram bot via BotFather and copy the token.

  5. 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_TOKEN configured, the bot exports logs, traces and these metrics:

    • bot.handler.calls_total
    • bot.handler.errors_total
    • bot.handler.duration_seconds
    • bot.chart.generation.total
    • bot.chart.generation.errors_total
    • bot.chart.generation.duration_seconds
  6. Run the bot:

    uv run python src/main.py

Docker

  1. Clone the repository:

    git clone https://github.com/halon176/h-crypto-price-bot.git
  2. Build the Docker image:

    docker build -t h-crypto-price h-crypto-price-bot/.
  3. 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

Usage

Get cryptocurrency prices using /p followed by the symbol:

/p btc
/p eth
/p sol

Type /help for a full list of available commands.

Contributing

Contributions are welcome! If you have any suggestions or bug reports, please open an issue on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A python-based bot that fetches real-time cryptocurrency prices from Coingecko and presents them in an easy-to-understand format on Telegram.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors