A simple CoinMarketCap scraper to fetch cryptocurrency data.
Project description
Coin API — simple CoinMarketCap scraper
A small, educational Python scraper that fetches basic data (price, 24h change, market cap) for a cryptocurrency from CoinMarketCap.
What it returns
- Price
- 24-hour change
- Market cap
Project files
coin_api/COIN_API.py— contains theCoinclass and a small demo loop when run as a module.requirements.txt— minimal dependency list (may need to add beautifulsoup4).
Requirements
- Python 3.8+
- requests
- beautifulsoup4
Install (PowerShell)
pip install -r requirements.txt
pip install beautifulsoup4
Or install both directly:
pip install requests beautifulsoup4
Usage (as a module)
from coin_api.COIN_API import Coin
coin = Coin("bitcoin") # coinmarketcap slug (e.g. "bitcoin", "ethereum")
data = coin.get_data() # returns a dict or False on error
print(data)
Run the included demo
python -m coin_api.COIN_API
Example output (subject to site HTML changes):
{
"Price": "$61,234.56",
"24h change": "+2.34% ↗️",
"Market cap": "$1,150,000,000,000"
}
Notes & limitations
- This scraper parses CoinMarketCap's public HTML. If the site changes structure, the parser may break.
- Avoid frequent automated requests; prefer official APIs (CoinMarketCap API, CoinGecko, Coinbase) for production use.
- Error handling in the code is minimal; consider adding timeouts, retries, logging, and clearer exceptions.
Suggested next steps I can implement
- Add a CLI entrypoint that accepts a coin slug and prints JSON.
- Add unit tests with mocked HTTP responses.
- Update
requirements.txtto pin dependency versions (e.g.requests==2.31.0,beautifulsoup4==4.12.2).
Author / Contact
faizan code — thetriquetradeveloper@gmail.com
If you want one of the suggested enhancements, tell me which and I'll implement it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coin_api-1.2.7.tar.gz.
File metadata
- Download URL: coin_api-1.2.7.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c95e200eb82794c8001970d28803db90221b2e3a4d41bf4bb6fbed52a8ab9e7c
|
|
| MD5 |
3391e579715f2d2be52a095cfe605f34
|
|
| BLAKE2b-256 |
aab4d61c859546152aef49812e826f0392fb45f01a4aa24d3a1d6cf3ceb54280
|
File details
Details for the file coin_api-1.2.7-py3-none-any.whl.
File metadata
- Download URL: coin_api-1.2.7-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df8cb11323140d283c524ff53b624da28edadeea58262619726f712868baf8e
|
|
| MD5 |
f33d101466b95a219ab2d66358d93df1
|
|
| BLAKE2b-256 |
87949833d9d94afcf7358ce338c23c4d73b40525bb5265f571ee33250f76be83
|