get_batch_historical_prices
Retrieve historical price data for multiple tokens at specified timestamps with adjustable search width. Ideal for analyzing crypto asset performance across different timeframes.
Instructions
GET /coins/batchHistorical
Get historical prices for multiple tokens at multiple different timestamps.
Parameters:
coins: dict where keys are coins in format {chain}:{address} and values are arrays of timestamps
search_width: time range on either side to find price data (default: '6h')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coins | Yes | ||
| search_width | No | 6h |
Implementation Reference
- defillama_server.py:642-659 (handler)The handler function that implements the get_batch_historical_prices tool. It constructs parameters from the input coins dictionary and search_width, makes an API request to DefiLlama's /coins/batchHistorical endpoint using the shared make_request helper, and returns the stringified result.async def get_batch_historical_prices( coins: Dict[str, List[int]], search_width: str = "6h" ) -> str: """GET /coins/batchHistorical Get historical prices for multiple tokens at multiple different timestamps. Parameters: coins: dict where keys are coins in format {chain}:{address} and values are arrays of timestamps search_width: time range on either side to find price data (default: '6h') """ params = { 'coins': str(coins), 'searchWidth': search_width } result = await make_request('GET', '/coins/batchHistorical', params) return str(result)
- defillama_server.py:641-641 (registration)The @mcp.tool() decorator registers the get_batch_historical_prices function as an MCP tool.@mcp.tool()