A command-line Python tool that fetches current cryptocurrency prices from CoinGecko and updates them at a user-defined interval (default: 5 minutes). This script is primarily designed for Windows environments, using msvcrt
for non-blocking user input.
Real-Time Price Fetching: Retrieves the latest price (in USD) for various coins from CoinGecko’s Simple Price API.
Coin Name Mappings: Includes a built-in dictionary (COINGECKO_ID_MAP
) for handling common coin names and tickers (e.g., BTC
, ETH
, DOGE
, etc.).
Auto-Update Loop: Continuously updates the selected coin’s price every 5 minutes (or until user input).
Interactive Input:
- Press Enter to change to a different coin.
- Type exit to terminate the program at any prompt. Error Handling: Gracefully handles network errors or mismatched coin names.
-
Initialization:
- Displays an ASCII banner.
- Prompts the user to enter a cryptocurrency name or ticker.
-
Coin Validation:
- The script checks the user’s input against the
COINGECKO_ID_MAP
dictionary. - If a match is found (e.g., input
BTC
→'bitcoin'
in the map), the corresponding CoinGecko ID is returned. - If no match is found, the user is prompted to enter a new coin name or exit.
- The script checks the user’s input against the
-
Fetching Prices:
- Using the identified CoinGecko ID, the script queries the CoinGecko Simple Price API to retrieve the coin’s current USD price.
- On success, it prints the fetched price to the console.
- On failure, it logs an error message indicating the issue (e.g., network error).
-
Continuous Update Loop:
- After fetching the price once, the script waits up to 5 minutes (300 seconds) before fetching the price again.
- The user can interrupt this waiting period by pressing Enter, allowing them to search for another coin or by typing exit to terminate the program.
-
User Input (Non-Blocking):
- The script uses
msvcrt
(a Windows-specific Python library) to detect keystrokes without blocking program execution. - If no input is detected within the specified timeout, the script proceeds to re-fetch the price.
- The script uses
-
Requirements:
- Python 3.6+
- Windows OS (due to
msvcrt
usage)
-
Python Libraries:
time
(standard library)sys
(standard library)msvcrt
(Windows-only standard library)requests
(third-party library for HTTP requests)
-
Install Required Libraries:
pip install requests
-
Clone or Download:
- Clone or download this repository or copy the script file into your local system.
-
Run the Script:
-
Enter the Coin:
- Input the ticker or name of the cryptocurrency when prompted (e.g.,
BTC
,ETH
,DOGE
,ADA
). - Press Enter to confirm.
- Input the ticker or name of the cryptocurrency when prompted (e.g.,
-
Wait for Updates:
- The script displays the current price and updates it every 5 minutes, unless interrupted by user input.
- Press Enter: Switch to a different coin.
- Type exit: Terminates the program at any prompt.
-
Fetch Interval:
- By default set to 5 minutes.
- You can adjust the
timeout
argument infetch_and_display_price(coin)
if you need to change it.
-
Coin Mapping:
- The dictionary
COINGECKO_ID_MAP
can be extended to include more coin name mappings or custom aliases.
- The dictionary
-
Windows-Only:
- The script uses
msvcrt
, which is exclusive to Windows. - To use it on MacOS or Linux, you would need to replace
msvcrt
with a different mechanism for non-blocking user input.
- The script uses
-
Network Reliability:
- Relies on an active internet connection to fetch live data from the CoinGecko API.
-
CoinGecko API Rate Limits:
- The free tier of the CoinGecko API can limit requests per minute. If you exceed these limits, you may receive errors or get temporarily blocked. Check CoinGecko’s API Documentation for more details.
-
Not an Investment Tool:
- The script is solely for informational purposes, and does not provide any financial or trading advice.
Error Fetching Price:
- Ensure you have a stable internet connection.
- Verify the coin name or ticker is included in the
COINGECKO_ID_MAP
dictionary. - Check if the CoinGecko API is online.
Script Closes Immediately:
- Run the script from a command prompt (e.g., PowerShell or CMD) to view output before it closes.
Keyboard Input Not Detected:
- Confirm you are using Windows.
- If you are using MacOS or Linux, you need a cross-platform approach for detecting keystrokes (e.g.,
select
orcurses
module).
Author: Joshus M Clatney (clats97) – Ethical Pentesting Enthusiast Version: 1.00
Disclaimer: This tool is provided “as is” for informational purposes only. Always verify prices with reliable sources before making financial decisions.
Copyright 2025 Johua M Clatney (Clats97)