> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coingecko.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DeFi & Onchain Analytics

> Analyze onchain tokens, pools, trades, and holder distribution across 200+ networks from CoinGecko API

<CardGroup cols={2}>
  <Card title="Set up your API key" icon="key" href="/docs/setting-up-your-api-key" horizontal arrow="true" />

  <Card title="Build faster with AI" icon="robot" href="/ai-integration#coding-agents" horizontal arrow="true" />
</CardGroup>

<Note>
  **TL;DR**<br />

  Use [/onchain/.../token\_price](/reference/onchain-simple-price) for onchain pricing, [/onchain/.../pools/.../ohlcv](/reference/pool-ohlcv-contract-address) for DEX charts, [/onchain/.../pools/.../trades](/reference/pool-trades-contract-address) for trade history, and [/onchain/.../tokens/.../top\_holders](/reference/top-token-holders-token-address) for wallet distribution.
</Note>

> Replace `YOUR_API_KEY` in the examples below with your actual key. [Get one here →](https://www.coingecko.com/en/api/pricing)

## Token Analytics

<Steps>
  <Step title="Onchain token pricing — /onchain/.../token_price/{addresses}">
    Real-time prices for any onchain token by contract address — including tokens not listed on CoinGecko. Batch multiple addresses in one call.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/simple/networks/eth/token_price/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x6b175474e89094c44da98b954eedeac495271d0f" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Onchain Simple Price →](/reference/onchain-simple-price)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/simple/networks/eth/token_price/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x6b175474e89094c44da98b954eedeac495271d0f" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Onchain Simple Price →](/demo/reference/onchain-simple-price)
      </Tab>
    </Tabs>

    <Tip>
      Use [/onchain/networks](/reference/networks-list) to get the full list of 200+ supported network IDs.
    </Tip>
  </Step>

  <Step title="Token market data — /onchain/.../tokens/{address}">
    Price, volume, FDV, market cap, price changes, and transaction counts for a token.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/tokens/0x6982508145454ce325ddbe47a25d4ec3d2311933?include=top_pools" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Token Data →](/reference/token-data-contract-address)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/networks/eth/tokens/0x6982508145454ce325ddbe47a25d4ec3d2311933?include=top_pools" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Token Data →](/demo/reference/token-data-contract-address)
      </Tab>
    </Tabs>

    | Key param | Use                                                     |
    | --------- | ------------------------------------------------------- |
    | `include` | `top_pools` to see the most active pools for this token |
  </Step>

  <Step title="Token metadata — /onchain/.../tokens/{address}/info">
    Description, socials, websites, CoinGecko ID, and GeckoTerminal analytics score.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/info" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Token Info →](/reference/token-info-contract-address)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/networks/eth/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/info" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Token Info →](/demo/reference/token-info-contract-address)
      </Tab>
    </Tabs>

    <Tip>
      The `coingecko_coin_id` field bridges onchain data to CoinGecko's main API — use it with [/coins/\{id}](/reference/coins-id) for community and developer metrics.
    </Tip>
  </Step>
</Steps>

***

## Pool Discovery & Liquidity

<Steps>
  <Step title="Pool details — /onchain/.../pools/{address}">
    Reserve (TVL), volume, price, transaction counts, and price changes for a specific pool.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640?include=base_token,quote_token,dex" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Pool Data →](/reference/pool-address)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/networks/eth/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640?include=base_token,quote_token,dex" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Pool Data →](/demo/reference/pool-address)
      </Tab>
    </Tabs>

    `reserve_in_usd` is your liquidity indicator — total value locked in the pool.
  </Step>

  <Step title="Trending pools — /onchain/networks/trending_pools">
    Hottest liquidity pools across all networks — spot early DeFi momentum.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/trending_pools?include=base_token,dex,network&duration=24h" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Trending Pools →](/reference/trending-pools-list) | [By Network →](/reference/trending-pools-network)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/networks/trending_pools?include=base_token,dex,network&duration=24h" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Trending Pools →](/demo/reference/trending-pools-list) | [By Network →](/demo/reference/trending-pools-network)
      </Tab>
    </Tabs>

    | Key param  | Use                                                              |
    | ---------- | ---------------------------------------------------------------- |
    | `include`  | `base_token`, `quote_token`, `dex`, `network` for richer context |
    | `duration` | `1h`, `6h`, or `24h` trending window                             |
  </Step>

  <Step title="Advanced screening — /onchain/pools/megafilter">
    Filter pools by volume, liquidity, age, network, DEX, and more — the most powerful pool discovery endpoint.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/pools/megafilter?networks=eth,solana&volume_24h_usd_min=100000&reserve_usd_min=50000&sort=volume_24h_usd_desc" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Pools Megafilter →](/reference/pools-megafilter)
      </Tab>

      <Tab title="Demo API">
        <Callout icon="key" color="#FFC107" iconType="regular">
          `/onchain/pools/megafilter` is not available on the Demo API.<br />
          [Upgrade to Pro →](https://www.coingecko.com/en/api/pricing)
        </Callout>
      </Tab>
    </Tabs>

    | Key param                    | Use                                             |
    | ---------------------------- | ----------------------------------------------- |
    | `networks`                   | Filter by chains (e.g. `eth,solana,base`)       |
    | `volume_24h_usd_min` / `max` | Volume thresholds                               |
    | `reserve_usd_min` / `max`    | Liquidity depth                                 |
    | `pool_age_min` / `max`       | Pool age in hours — find new pools              |
    | `sort`                       | `volume_24h_usd_desc`, `reserve_usd_desc`, etc. |
  </Step>
</Steps>

***

## DEX Charts & Trades

<Steps>
  <Step title="Pool OHLCV — sub-minute candles">
    OHLCV for a specific pool with `second`, `minute`, `hour`, and `day` timeframes.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        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"
        ```

        > [Pool OHLCV →](/reference/pool-ohlcv-contract-address)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/networks/eth/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv/minute?aggregate=5&limit=100&currency=usd" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Pool OHLCV →](/demo/reference/pool-ohlcv-contract-address)
      </Tab>
    </Tabs>

    Response format: `[timestamp, open, high, low, close, volume]`.

    | Key param   | Use                                                   |
    | ----------- | ----------------------------------------------------- |
    | `aggregate` | Combine candles — `5` for 5-min, `4` for 4-hour       |
    | `limit`     | Up to 1000 data points                                |
    | `currency`  | `usd` for fiat or `token` for base-token denomination |
  </Step>

  <Step title="Token OHLCV — aggregated across pools">
    Same format as pool OHLCV, but aggregated across all pools for a token — broader market view.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/tokens/0x6982508145454ce325ddbe47a25d4ec3d2311933/ohlcv/day?aggregate=1&limit=30&currency=usd" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Token OHLCV →](/reference/token-ohlcv-token-address)
      </Tab>

      <Tab title="Demo API">
        <Callout icon="key" color="#FFC107" iconType="regular">
          `/onchain/.../tokens/.../ohlcv` is not available on the Demo API.<br />
          [Upgrade to Pro →](https://www.coingecko.com/en/api/pricing)
        </Callout>
      </Tab>
    </Tabs>

    <Note>
      Pool OHLCV reflects a single pool's price action. Token OHLCV aggregates across all pools — use it for a broader market view.
    </Note>
  </Step>

  <Step title="Pool trades — last 300 trades">
    Recent swap activity for a specific pool — monitor execution or trigger alerts on large trades.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        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"
        ```

        > [Pool Trades →](/reference/pool-trades-contract-address)
      </Tab>

      <Tab title="Demo API">
        ```bash theme={null}
        curl -X GET \
          "https://api.coingecko.com/api/v3/onchain/networks/eth/pools/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/trades?trade_volume_in_usd_greater_than=10000" \
          -H "x-cg-demo-api-key: YOUR_API_KEY"
        ```

        > [Pool Trades →](/demo/reference/pool-trades-contract-address)
      </Tab>
    </Tabs>

    <Tip>
      Use [Token Trades](/reference/token-trades-contract-address) for a cross-pool view of all trading activity for a token (Pro only).
    </Tip>
  </Step>
</Steps>

***

## Token Holder Analytics

<Steps>
  <Step title="Top holders — /onchain/.../tokens/{address}/top_holders">
    Wallet addresses, balances, and ownership percentages for the largest holders. The `wallet_tag` field identifies known entities (exchanges, protocols, treasuries).

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/tokens/0x6982508145454ce325ddbe47a25d4ec3d2311933/top_holders" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Top Holders →](/reference/top-token-holders-token-address)
      </Tab>

      <Tab title="Demo API">
        <Callout icon="key" color="#FFC107" iconType="regular">
          `/onchain/.../tokens/.../top_holders` is not available on the Demo API.<br />
          [Upgrade to Pro →](https://www.coingecko.com/en/api/pricing)
        </Callout>
      </Tab>
    </Tabs>
  </Step>

  <Step title="Holder count over time — /onchain/.../tokens/{address}/holders_chart">
    Historical holder count — rising count signals adoption, declining count may indicate distribution concerns.

    <Tabs>
      <Tab title="Pro API">
        ```bash theme={null}
        curl -X GET \
          "https://pro-api.coingecko.com/api/v3/onchain/networks/eth/tokens/0x6982508145454ce325ddbe47a25d4ec3d2311933/holders_chart?timeframe=one_month" \
          -H "x-cg-pro-api-key: YOUR_API_KEY"
        ```

        > [Holders Chart →](/reference/token-holders-chart-token-address)
      </Tab>

      <Tab title="Demo API">
        <Callout icon="key" color="#FFC107" iconType="regular">
          `/onchain/.../tokens/.../holders_chart` is not available on the Demo API.<br />
          [Upgrade to Pro →](https://www.coingecko.com/en/api/pricing)
        </Callout>
      </Tab>
    </Tabs>

    <Tip>
      Combine top holders with the holders chart — top holders shows current concentration, the chart reveals adoption trends over time.
    </Tip>
  </Step>
</Steps>
