Skip to content

Retrieves top cryptocurrencies from the CoinGecko API, including price, market cap, volume, and 24h change, exports structured CSVs.

License

Notifications You must be signed in to change notification settings

mdugan8186/coingecko-scraper

Repository files navigation

CoinGecko API Scraper

Retrieves top cryptocurrencies → structured CSVs with price and market data.

Python License: MIT Last Commit

A Python scraper that queries the CoinGecko public API for cryptocurrency market data.
It retrieves the top N coins by market cap, parses the JSON response, and exports clean CSVs for analysis.


🔍 Key Features

  • Retrieves top cryptocurrencies by market cap (default: 100).
  • Structured fields exported to CSV: name, symbol, current_price, market_cap, volume_24h, price_change_24h_pct.
  • Lightweight (uses Python + requests/httpx).
  • Error handling for network failures and API rate limits.
  • Easy to extend with custom fields or output formats.

⚙️ Quick Start

Prerequisites

  • Python 3.10+
  • Git

Installation

# 1) Clone
git clone https://github.com/mdugan8186/coingecko-scraper.git
cd coingecko-scraper

# 2) (optional) Virtual environment
python -m venv .venv
# macOS/Linux:
source .venv/bin/activate
# Windows:
.venv\Scripts\activate

# 3) Dependencies
pip install -r requirements.txt

Run

python main.py
  • Outputs a CSV at: output/top_100_crypto_2025-07-29_22-38-18.csv
  • Each run creates a timestamped CSV (e.g., top_100_crypto_2025-07-29_22-38-18.csv). Older files are not overwritten.

📁 Output

  • Timestamped CSVs saved in output/ (e.g., top_100_crypto_2025-07-29_22-38-18.csv).

Columns

name, symbol, current_price, market_cap, volume_24h, price_change_24h_pct

🎥 Demo

Example of the scraper output:

CoinGecko Output

The full dataset is saved as: output/top_100_crypto_2025-07-29_22-38-18.csv


🧪 Testing & Dev Notes

See TESTING.md for a step-by-step sanity flow, API maintenance notes, and data-quality checks.


🛠️ Tech Stack

  • Python (3.10+)
  • requests / httpx for API calls
  • CSV outputs (pandas optional for further cleaning)

⚖️ Legal & Ethical Use

This scraper uses the CoinGecko public API and is intended for educational and demonstration purposes only.
Please review and comply with the CoinGecko API Terms of Service before using this project beyond small-scale testing or portfolio demonstration.


📄 License

This project is licensed under the MIT License. See LICENSE.


👤 About

Mike Dugan — Python Web Scraper & Automation Developer

About

Retrieves top cryptocurrencies from the CoinGecko API, including price, market cap, volume, and 24h change, exports structured CSVs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages