Skip to main content

TL;DR

Use /simple/price for low-latency spot prices, /coins/{id}/ohlc for candlestick charts, /coins/{id}/market_chart/range for backtesting, and the onchain /ohlcv/{timeframe} endpoints for second-level granularity on DEX pools.

Real-time market data is the backbone of any trading system — whether you’re building an automated bot, a custom charting interface, or backtesting a strategy against historical data. This guide walks you through the CoinGecko API endpoints that matter most for trading workflows, and ties them together into a complete workflow at the end:
  • Fetching real-time prices for execution logic and portfolio valuation
  • Pulling OHLC candle data at multiple granularities for technical analysis
  • Accessing historical market data to backtest and validate strategies
  • Tracking onchain trades and liquidity for DeFi execution
Estimated reading time: 10 minutes
Want to get started even faster?
Copy the contents of this page from trading.md and paste it directly into your AI tool for instant context.

Navigate the API faster with AI

Install the CoinGecko SKILL to give your AI coding agent built-in knowledge of every endpoint, parameter, and workflow. Setup takes less than 3 minutes.

Endpoint Overview

EndpointWhat It Gives YouBest For
/simple/priceReal-time spot prices with optional market cap, volume, and 24h changeLow-latency price feeds for execution logic
/coins/marketsBulk market data for multiple coins in a single callScreening and ranking assets by volume or price change
/coins/{id}/ohlcOpen-High-Low-Close candlesTechnical analysis and candlestick charting
/coins/{id}/ohlc/rangeOHLC candles for a custom date rangeBacktesting with precise time windows
/coins/{id}/market_chart/rangePrice, market cap, and volume over a custom date rangeHistorical backtesting and trend analysis
/coins/{id}/tickersTrading pairs across CEXs and DEXs with bid/ask and volumeFinding best execution venue
/onchain/networks/../pools/../ohlcv/..Pool-level OHLCV with minute and second granularityHigh-frequency DEX trading strategies
/onchain/networks/../pools/../tradesLast 300 trades in the past 24 hours for a poolExecution monitoring and market microstructure
Replace YOUR_API_KEY in the examples below with your actual CoinGecko API key.
Don’t have one yet? Get your API key here.

Real-Time Prices — /simple/price

🔗 More endpoint details here The fastest way to get current prices. This endpoint supports querying multiple coins in a single request and returns data with minimal overhead — ideal for polling in a trading loop. Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd&include_24hr_vol=true&include_24hr_change=true" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Key parameters:
ParameterWhy It Matters
ids / symbolsQuery by CoinGecko ID or ticker symbol — use whichever fits your data model
vs_currenciesGet prices in multiple fiat or crypto currencies simultaneously
include_24hr_volEssential for volume-weighted execution decisions
include_24hr_changeUseful for momentum-based strategies
precisionControl decimal precision to match your system’s requirements
Response highlights:
{
  "bitcoin": {
    "usd": 67432.51,
    "usd_24h_vol": 28394567890.12,
    "usd_24h_change": 2.34567
  },
  "ethereum": {
    "usd": 3456.78,
    "usd_24h_vol": 15234567890.45,
    "usd_24h_change": 1.23456
  }
}
For onchain tokens not listed on CoinGecko, use the Onchain Simple Price endpoint instead — it returns real-time prices by contract address across any supported network.

Market Screening — /coins/markets

🔗 More endpoint details here When you need to scan across many assets at once — for example, to rank coins by 24h volume or identify top movers — this endpoint returns rich market data in bulk. Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=volume_desc&per_page=50&page=1&price_change_percentage=1h,24h,7d" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Key parameters:
ParameterWhy It Matters
orderSort by volume_desc to surface the most liquid assets first
price_change_percentageInclude 1h,24h,7d to spot momentum across multiple timeframes
per_pageUp to 250 results per page — reduces the number of calls needed
Response highlights:
{
  "id": "bitcoin",
  "symbol": "btc",
  "current_price": 67432.51,
  "market_cap": 1326789012345,
  "total_volume": 28394567890,
  "price_change_percentage_1h_in_currency": 0.12,
  "price_change_percentage_24h_in_currency": 2.34,
  "price_change_percentage_7d_in_currency": 5.67,
  "high_24h": 68100.00,
  "low_24h": 65800.00
}

OHLC Candle Data

/coins/{id}/ohlc

🔗 More endpoint details here Returns Open-High-Low-Close candle data — the foundation for candlestick charts and most technical indicators (RSI, MACD, Bollinger Bands, etc.). Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/coins/bitcoin/ohlc?vs_currency=usd&days=30" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Response format:
[
  [1709424000000, 62345.12, 62890.45, 62100.00, 62567.89],
  [1709438400000, 62567.89, 63100.00, 62400.00, 62890.12]
]
Each array entry is [timestamp, open, high, low, close].
The timestamp marks the close time of the candle.
Candle granularity is automatic based on the days parameter:
  • 1-2 days: 30-minute candles
  • 3-30 days: 4-hour candles
  • 31+ days: 4-day candles
Paid plan subscribers can override this with interval=daily or interval=hourly:
  • daily works for 1, 7, 14, 30, 90, and 180 days
  • hourly works for 1, 7, 14, 30, and 90 days

/coins/{id}/ohlc/range

🔗 More endpoint details here When you need OHLC data for a specific time window — perfect for backtesting a strategy against a defined period. Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/coins/bitcoin/ohlc/range?vs_currency=usd&from=2024-01-01&to=2024-06-30&interval=daily" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
The from and to parameters accept both ISO date strings and UNIX timestamps, giving you flexibility in how you define your backtest window.

Historical Data for Backtesting — /coins/{id}/market_chart/range

🔗 More endpoint details here Returns price, market cap, and total volume over a custom date range — ideal when your strategy depends on more than just OHLC (e.g., volume-weighted signals or market cap thresholds). Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/coins/ethereum/market_chart/range?vs_currency=usd&from=2024-01-01&to=2024-12-31" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Response highlights:
{
  "prices": [
    [1704067200000, 2282.51],
    [1704153600000, 2356.78]
  ],
  "market_caps": [
    [1704067200000, 274256789012],
    [1704153600000, 283156789012]
  ],
  "total_volumes": [
    [1704067200000, 8234567890],
    [1704153600000, 9123456789]
  ]
}
Data granularity is automatic based on the date range. Leave the interval parameter empty for auto granularity, or specify daily or hourly for consistent data points.

Cross-Exchange Execution — /coins/{id}/tickers

🔗 More endpoint details here Shows where a coin is traded and at what price — across both centralized and decentralized exchanges. This is invaluable for finding the best execution venue or identifying arbitrage opportunities. Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/coins/bitcoin/tickers?exchange_ids=binance,coinbase&depth=true&order=volume_desc" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Key parameters:
ParameterWhy It Matters
exchange_idsFilter to specific exchanges you actually trade on
depthIncludes cost-to-move-price (2% bid/ask spread metrics) — critical for large orders
orderSort by volume_desc to prioritize the most liquid pairs
Response highlights:
{
  "tickers": [
    {
      "base": "BTC",
      "target": "USDT",
      "market": {
        "name": "Binance",
        "identifier": "binance"
      },
      "last": 67432.51,
      "volume": 12345.67,
      "bid_ask_spread_percentage": 0.01,
      "cost_to_move_up_usd": 523456.78,
      "cost_to_move_down_usd": 498765.43,
      "trust_score": "green"
    }
  ]
}
The cost_to_move_up_usd and cost_to_move_down_usd fields tell you how much capital it takes to move the price by 2% in either direction — a direct measure of market depth.

Onchain DEX Trading

For DeFi-native strategies, the onchain endpoints provide granular, pool-level data that you won’t find in traditional market data feeds.

Pool OHLCV with Sub-Minute Granularity — /onchain/networks/../pools/../ohlcv/..

🔗 More endpoint details here The Pool OHLCV and Token OHLCV endpoints support day, hour, minute, and second timeframes — with customizable aggregation periods (e.g., 5-minute or 15-minute candles). Example request (5-minute candles for a Uniswap V3 ETH/USDC pool):
curl -X GET "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv/minute?aggregate=5&limit=100&currency=usd" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Key parameters:
ParameterWhy It Matters
timeframeChoose second, minute, hour, or day
aggregateCombine candles (e.g., 5 for 5-minute candles, 4 for 4-hour candles)
limitUp to 1000 data points per request
before_timestampPaginate backward in time for historical data
currencyusd for fiat-denominated or token for base-token denomination
Response highlights:
{
  "data": {
    "attributes": {
      "ohlcv_list": [
        [1709424300, 3456.78, 3462.10, 3450.00, 3458.90, 1234567.89]
      ]
    }
  }
}
Each entry is [timestamp, open, high, low, close, volume].

Onchain Trade Feed — /onchain/networks/../pools/../trades

🔗 More endpoint details here The Pool Trades endpoint returns the last 300 trades in the past 24 hours for a specific pool — useful for monitoring execution, analyzing market microstructure, or triggering alerts on large swaps. Example request:
curl -X GET "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/trades?trade_volume_in_usd_greater_than=10000" \
  -H "x-cg-pro-api-key: YOUR_API_KEY"
Key parameters:
ParameterWhy It Matters
trade_volume_in_usd_greater_thanFilter out noise — only see trades above your threshold
Response highlights:
{
  "data": [
    {
      "attributes": {
        "block_number": 19345678,
        "block_timestamp": "2024-03-15T10:30:00Z",
        "kind": "buy",
        "volume_in_usd": "52345.67",
        "from_token_amount": "15.234",
        "to_token_amount": "52345.67",
        "price_from_in_usd": "3437.12",
        "tx_hash": "0xabc...def"
      }
    }
  ]
}
Use the Token Trades endpoint to see trades across all pools for a given token, rather than a single pool.

Putting It All Together

Here’s how these endpoints fit into a typical trading workflow:
  1. Screen and select assets — Use /coins/markets to rank by volume and momentum
  2. Monitor real-time prices — Poll /simple/price for low-latency price updates
  3. Analyze charts — Fetch /coins/{id}/ohlc for technical analysis
  4. Find execution venues — Query /coins/{id}/tickers with depth=true for best spread and liquidity
  5. Backtest strategies — Pull historical data from /coins/{id}/ohlc/range or /coins/{id}/market_chart/range
  6. Trade onchain — Use onchain OHLCV for sub-minute signals and the trades endpoint for execution monitoring

Integrate with CoinGecko MCP Server

Connect your AI agent directly to CoinGecko’s API using our MCP server — enabling real-time crypto data queries from tools like Claude Desktop, Cursor, and more.

Have feedback or need help? Reach out to eason.lim@coingecko[dot]com