get_closest_block
Retrieve the closest blockchain block for a specific timestamp using a chain identifier. Simplify timestamp-based block queries for crypto data analysis and retrieval.
Instructions
GET /coins/block/{chain}/{timestamp}
Get the closest block to a timestamp.
Parameters:
chain: chain identifier
timestamp: UNIX timestamp to find closest block for
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | Yes | ||
| timestamp | Yes |
Implementation Reference
- defillama_server.py:733-744 (handler)Handler and registration for the 'get_closest_block' tool. Queries DefiLlama API for the closest block to a given timestamp on a specified chain.@mcp.tool() async def get_closest_block(chain: str, timestamp: int) -> str: """GET /coins/block/{chain}/{timestamp} Get the closest block to a timestamp. Parameters: chain: chain identifier timestamp: UNIX timestamp to find closest block for """ result = await make_request('GET', f'/coins/block/{chain}/{timestamp}') return str(result)