A simple Python script for fetching the current price of a cryptocurrency using the CoinGecko API.
This script demonstrates how to retrieve the current price of a cryptocurrency by providing its symbol. It utilizes the CoinGecko API, which offers real-time cryptocurrency data.
- Fetches the current price of a cryptocurrency.
- Supports various cryptocurrency symbols (e.g., BTC, ETH).
- Utilizes the CoinGecko API for accurate and up-to-date data.
-
Ensure that you have the
requests
library installed:pip install requests
-
Run the script:
python crypto_price_checker.py
-
Enter the cryptocurrency symbol when prompted.
# Example usage
crypto_symbol = input("Enter the cryptocurrency symbol (e.g., BTC, ETH): ")
crypto_price = get_crypto_price(crypto_symbol)
if crypto_price is not None:
print(f"Current price of {crypto_symbol}: ${crypto_price}")
else:
print(f"Failed to fetch the price of {crypto_symbol}")