# CoinGecko Crypto Scraper (`cloud9_ai/coingecko-crypto-scraper`) Actor

Extract cryptocurrency market data from CoinGecko: price, market cap, 24h volume, circulating supply, price changes (1h/24h/7d/30d), ATH/ATL, sparkline. Sort by market cap, volume, trend. Filter by category (DeFi, NFT, Layer 1). Real-time data via CoinGecko API.

- **URL**: https://apify.com/cloud9\_ai/coingecko-crypto-scraper.md
- **Developed by:** [cloud9](https://apify.com/cloud9_ai) (community)
- **Categories:** AI, Automation
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## CoinGecko Cryptocurrency Scraper

Apify Actor for scraping cryptocurrency market data from CoinGecko.

### Features

- **Comprehensive Data**: Prices, market cap, volume, supply, price changes
- **Flexible Inputs**: Scrape by category, page, or custom URL
- **Rate Limiting**: Built-in delays to respect server limits
- **Retry Logic**: Exponential backoff for failed requests
- **Proxy Support**: Uses Apify residential proxies
- **User-Agent Rotation**: Reduces detection risk

### Input Schema

```json
{
  "searchUrl": "https://www.coingecko.com/",
  "category": "decentralized-finance-defi",
  "page": 1,
  "perPage": 100,
  "sortBy": "market_cap_desc",
  "maxResults": 100
}
```

#### Input Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `searchUrl` | string | - | Custom CoinGecko URL to scrape |
| `category` | string | - | Category slug (e.g., "decentralized-finance-defi") |
| `page` | number | 1 | Starting page number |
| `perPage` | number | 100 | Results per page (max 100) |
| `sortBy` | string | - | Sort order (e.g., "market\_cap\_desc") |
| `maxResults` | number | 100 | Maximum results to return |

### Output Schema

```json
{
  "name": "Bitcoin",
  "symbol": "BTC",
  "rank": 1,
  "price": 45000.50,
  "marketCap": 880000000000,
  "volume24h": 25000000000,
  "circulatingSupply": 19500000,
  "totalSupply": 21000000,
  "change1h": 0.5,
  "change24h": 2.3,
  "change7d": -1.2,
  "change30d": 5.6,
  "ath": 69000,
  "athDate": "2021-11-10",
  "atl": 67.81,
  "atlDate": "2013-07-06",
  "imageUrl": "https://.../",
  "coinGeckoUrl": "https://www.coingecko.com/en/coins/bitcoin",
  "sparkline7d": [44000, 44500, ...]
}
```

### Usage Examples

#### Scrape Top 100 Cryptocurrencies

```json
{
  "maxResults": 100
}
```

#### Scrape DeFi Category

```json
{
  "category": "decentralized-finance-defi",
  "maxResults": 50
}
```

#### Scrape Specific Page

```json
{
  "page": 3,
  "maxResults": 100
}
```

#### Custom URL

```json
{
  "searchUrl": "https://www.coingecko.com/en/categories/layer-1",
  "maxResults": 200
}
```

### Development

#### Local Testing

```bash
## Install dependencies
npm install

## Build TypeScript
npm run build

## Run locally
npm start
```

#### Build Docker Image

```bash
docker build -t coingecko-scraper .
docker run -it coingecko-scraper
```

### Technical Details

#### Architecture

- **TypeScript**: Type-safe implementation
- **gotScraping**: HTTP client with proxy support
- **Cheerio**: Fast HTML parsing
- **Apify SDK**: Actor framework

#### Rate Limiting

- 2-3 second delay between pages
- Exponential backoff on errors (2s, 4s, 8s)
- Maximum 3 retry attempts per request

#### Proxy Configuration

Uses Apify's residential proxy pool via `APIFY_PROXY_URL` environment variable.

#### User-Agent Rotation

Rotates between 5 common browser user agents to reduce detection.

### Limitations

- CoinGecko may update their HTML structure
- Some advanced metrics require individual coin pages
- Rate limits may apply on free proxies

### License

MIT

# Actor input Schema

## `searchUrl` (type: `string`):

Custom CoinGecko URL to scrape (overrides other parameters)

## `category` (type: `string`):

Category slug to scrape (e.g., 'decentralized-finance-defi', 'layer-1', 'meme-token')

## `page` (type: `integer`):

Page number to start scraping from

## `perPage` (type: `integer`):

Number of results per page (typically 100 on CoinGecko)

## `sortBy` (type: `string`):

Sort order for results

## `maxResults` (type: `integer`):

Maximum number of cryptocurrencies to scrape

## Actor input object example

```json
{
  "searchUrl": "https://www.coingecko.com/en/categories/layer-1",
  "category": "decentralized-finance-defi",
  "page": 1,
  "perPage": 100,
  "sortBy": "market_cap_desc",
  "maxResults": 100
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("cloud9_ai/coingecko-crypto-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("cloud9_ai/coingecko-crypto-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call cloud9_ai/coingecko-crypto-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cloud9_ai/coingecko-crypto-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hzeHd3VAWOQY9U2Yk/builds/4H2U35xHTlLpt4UMw/openapi.json
