4. Get On-Chain Data
Here are some of the important parameters to take note while using On-Chain DEX API Endpoints:
- Blockchain Networks
- DEXes
- Pool Contract Address
- Token Contract Address
Blockchain Networks
Notes
- Please do not use CoinGecko Asset Platform ID as the Network ID in On-Chain DEX API Endpoints (CoinGecko Asset Platform ID β GT Network ID)**
- Example:
- Asset Platform on CoinGecko:
ethereum
- On-Chain Network ID:
eth
How to obtain Network ID?
-
Use /onchain/networks endpoint
Example of responses:{ "data": [ { "id": "eth", π Network ID "type": "network", "attributes": { "name": "Ethereum", "coingecko_asset_platform_id": "ethereum" π CoinGecko Asset Platform ID } }, ...... ] }
-
Go to GeckoTerminal
- Select or search for a blockchain network
- Copy the slug from the URL
DEXes
Some of the pools endpoints require you to provide DEX ID along with Network ID to query the pools on a particular DEX (Decentralized Exchange)
Using /onchain/networks/{network}/dexes/{dex}/pools as example:
https://pro-api.coingecko.com/api/v3/onchain/networks/eth/dexes/uniswap_v3/pools?x_cg_pro_api_key=YOUR_API_KEY
There are 2 parameter values required to apply for this endpoint:
- network:
eth
(network id) - dex:
uniswap_v3
(dex id)
How to obtain DEX ID?
-
Use /onchain/networks/{network}/dexes endpoint
Example of responses:{ "data": [ { "id": "uniswap_v2", π DEX ID "type": "dex", "attributes": { "name": "Uniswap V2" } }, ...... ] }
-
Go to GeckoTerminal
- Select or search for a blockchain network
- Choose the DEX from the DEXes List on the top (Eg. Uniswap V3)
- Copy the slug from the URL
Methods to query On-Chain Data
a. Pool Contract Address
Most of the time, you will need a pool contract address along with Network ID to query the on-chain data, especially when using the Pools Endpoints
Using /onchain/networks/{network}/pools/{address} as example:
https://pro-api.coingecko.com/api/v3/onchain/networks/eth/pools/0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc?x_cg_pro_api_key=YOUR_API_KEY
There are 2 parameter values required to apply for this endpoint:
- network:
eth
(network id) - address:
0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc
(pool contract address)
How to obtain the pool contract address? (Eg. WETH/USDC)
-
Look for the contract address section of pool page on GeckoTerminal
-
Get the pool contract address from the project website, whitepaper, documentation, or block explorer site
b. Token Contract Address
Apart from the pool contract address, you also have the option to query on-chain data by using the token contract address
Using /onchain/networks/{network}/tokens/{token_address}/pools as example:
https://pro-api.coingecko.com/api/v3/onchain/networks/eth/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/pools?x_cg_pro_api_key=YOUR_API_KEY
There are 2 parameter values required to apply for this endpoint:
- network:
eth
(network id) - address:
0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
(token contract address)
How to obtain tokens contract address (Eg. UNI):
-
Look for the contract address section of pool page on GeckoTerminal
-
Get the token contract address from the project website, whitepaper, documentation, or block explorer site. For example:
Updated 10 months ago