A lightweight Python script that fetches cryptocurrency market capitalization data from CoinGecko’s public API. Designed for easy integration, full debugging, and open-source contributions.
- Retrieve a full list of coins from CoinGecko
- Look up a coin’s ID by its symbol
- Fetch USD market capitalization for any supported symbol
- Detailed logging at HTTP, library, and application levels
- Async-friendly entrypoint for seamless workflow integration
- Python 3.8 or newer
- Internet access
-
Clone the repository
git clone https://github.com/yourusername/how-to-get-market-cap-from-CoinGecko-without-API.git cd how-to-get-market-cap-from-CoinGecko-without-API
-
Create and activate a virtual environment (optional but recommended)
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies
pip install -r requirements.txt
requirements.txt should include:
requests>=2.25.0 telethon>=1.24.0 # optional: for Telegram integration
-
Import and call the async function
import asyncio from marketcap_retriever import marketcap_retrieve_operations async def main(): # Use format "<symbol>_anytag", e.g. "btc_demo" await marketcap_retrieve_operations("eth_demo") asyncio.run(main())
-
Output
-
Script logs the USD market cap for the given symbol.
-
Example log:
INFO:__main__:Market cap of ETH from CoinGecko: 183456789012.34 USD
-
-
Logging Levels
- Default:
DEBUG
for full visibility. - Adjust in
logging.basicConfig(level=logging.DEBUG)
.
- Default:
-
Rate Limits
- CoinGecko public API allows up to 50 calls/minute.
- Implement caching or delays for high-frequency calls.
Function | Description |
---|---|
get_coingecko_coin_list() |
Fetches full coin list (ID, symbol, name) from CoinGecko. |
get_market_cap_from_coingecko(symbol, list) |
Finds coin ID by symbol and retrieves its USD market cap. |
marketcap_retrieve_operations(ticker) |
Async entrypoint: splits ticker, retrieves list, fetches cap. |
- Uses Python’s
logging
module atDEBUG
level. - HTTP debug via
http.client.debuglevel = 1
. - Third-party libs (
requests
,urllib3
,telethon
) set toDEBUG
.
- Fork the repo
- Create a branch:
git checkout -b feature/my-feature
- Commit changes:
git commit -m "Add my feature"
- Push:
git push origin feature/my-feature
- Open a Pull Request
Please follow PEP 8 and include tests for new functionality.
This project is licensed under the MIT License. See LICENSE for details.