get_token_data
Retrieve token information by contract address to analyze DeFi assets, including network data and optional liquidity pool details for trading decisions.
Instructions
Get specific token data by contract address
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | Yes | Network ID (e.g., 'eth', 'bsc', 'polygon_pos') | |
| address | Yes | Token contract address | |
| include | No | Attributes to include: 'top_pools' (optional) |
Implementation Reference
- Core handler implementation: Makes HTTP request to CoinGecko API to fetch token data by network and address.
async getTokenData(network, address, options = {}) { try { const queryParams = new URLSearchParams(); if (options.include) queryParams.append('include', options.include); const url = `${this.baseUrl}/networks/${network}/tokens/${address}${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 token data: ${error.message}`); } }