4. Get On-chain Data
Here are some of the important parameters to take note of while using Onchain DEX API Endpoints:
- Blockchain Networks
- DEXs
- Pool Contract Address
- Token Contract Address
Blockchain Networks
Notes
-
Please do not use CoinGecko Asset Platform ID as the Network ID in Onchain DEX API Endpoints (CoinGecko Asset Platform ID ≠ GT Network ID)
-
Example:
- Asset Platform on CoinGecko:
ethereum - Onchain Network ID:
eth
- Asset Platform on CoinGecko:
How to obtain Network ID?
-
Use /onchain/networks endpoint, example of response:
JSON -
Go to GeckoTerminal
-
Select or search for a blockchain network.
-
Copy the slug from the URL:
-
DEXs
Some of the pools endpoints require you to provide a DEX ID along with a Network ID to query the pools on a particular DEX (Decentralized Exchange).
Using the /onchain/networks/{network}/dexes/{dex}/pools endpoint as an 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 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 response:
JSON -
Go to GeckoTerminal
-
Select or search for a blockchain network.
-
Choose the DEX from the DEXs List on the top (e.g. Uniswap V3).
-
Copy the slug from the URL:
-
Methods to query Onchain Data
a. Pool Contract Address
Most of the time, you will need a pool contract address along with a Network ID to query the onchain data, especially when using the Pools Endpoints.
Using the /onchain/networks/{network}/pools/{address} endpoint as an 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 for this endpoint:
network:eth(network ID)address:0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc(pool contract address)
How to obtain the pool contract address? (e.g. WETH/USDC)
-
Look for the contract address section of the pool page on GeckoTerminal:
-
Get the pool contract address from the project website, white-paper, documentation, or block explorer site:
b. Token Contract Address
Apart from the pool contract address, you also have the option to query onchain data by using the token contract address, using the /onchain/networks/{network}/tokens/{token_address}/pools endpoint as an 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 for this endpoint:
network:eth(network ID)address:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48(token contract address)
How to obtain token contract address (e.g. UNI):
-
Look for the contract address section of the token page on GeckoTerminal:
-
Get the token contract address from the project website, white-paper, documentation, or block explorer site. For example:
