get_historical_prices
Retrieve historical cryptocurrency token prices by contract address and timestamp for analysis and tracking.
Instructions
GET /coins/prices/historical/{timestamp}/{coins}
Get historical prices of tokens by contract address.
Parameters:
timestamp: UNIX timestamp for historical prices
coins: comma-separated tokens in format {chain}:{address}
search_width: time range on either side to find price data (default: '6h')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timestamp | Yes | ||
| coins | Yes | ||
| search_width | No | 6h |
Implementation Reference
- defillama_server.py:622-639 (handler)The handler function decorated with @mcp.tool() that implements the get_historical_prices tool. It fetches historical token prices from the DefiLlama API using the provided timestamp, coins, and search width.@mcp.tool() async def get_historical_prices( timestamp: int, coins: str, search_width: str = "6h" ) -> str: """GET /coins/prices/historical/{timestamp}/{coins} Get historical prices of tokens by contract address. Parameters: timestamp: UNIX timestamp for historical prices coins: comma-separated tokens in format {chain}:{address} search_width: time range on either side to find price data (default: '6h') """ params = {'searchWidth': search_width} result = await make_request('GET', f'/coins/prices/historical/{timestamp}/{coins}', params) return str(result)