get_top_pools_by_token
Find the most active liquidity pools for any token by contract address across multiple blockchains to analyze trading opportunities.
Instructions
Get top pools for a specific token by contract address
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| tokenAddress | Yes | Token contract address | |
| include | No | Attributes to include: 'base_token', 'quote_token', 'dex' (comma-separated) | |
| page | No | Page number for pagination (optional, default: 1) | |
| sort | No | Sort by: 'h24_volume_usd_liquidity_desc', 'h24_tx_count_desc', 'h24_volume_usd_desc' (optional, default: 'h24_volume_usd_liquidity_desc') |
Implementation Reference
- Core helper function that performs the HTTP request to CoinGecko's onchain API to fetch top pools for a given token.
async getTopPoolsByToken(network, tokenAddress, options = {}) { try { const queryParams = new URLSearchParams(); if (options.include) queryParams.append('include', options.include); if (options.page) queryParams.append('page', options.page); if (options.sort) queryParams.append('sort', options.sort); const url = `${this.baseUrl}/networks/${network}/tokens/${tokenAddress}/pools${queryParams.toString() ? '?' + queryParams.toString() : ''}`; const response = await fetch(url, { headers: { 'x-cg-demo-api-key': this.apiKey } }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } return await response.json(); } catch (error) { throw new Error(`Failed to get top pools by token: ${error.message}`); } }