{"data":{"billing":{"currency":"USD","mode":"fixed","priceMicroUsd":"0","rounding":null,"unit":"call","unitQuantity":null},"capabilityId":"ed3b3c54-d1ee-49ff-9413-635712d880d1","catalogType":"api","categories":["data","finance","crypto-defi"],"dataPlatform":"DefiLlama","dataPlatformLogoUrl":"https://api-docs.defillama.com/icons/favicon-96x96.png","dataPlatformTranslations":{"ar":"DefiLlama","ja":"DefiLlama","zh":"DefiLlama"},"dataProduct":"prices","description":"Get DefiLlama Closest Block data via REST or OpenAny MCP—with pay-per-use pricing and no subscription. Powered by DeFiLlama, configure supported query parameters and filters, and retrieve structured data including height for pin archive-node eth_call queries, align governance snapshots, and pair blocks with historical prices, ready for production pipelines and AI agent automation.","descriptionTranslations":{"ar":"اعثر على أقرب رقم كتلة بلوكشين لأي طابع زمني عبر OpenAny REST لتحديد الحالة التاريخية على السلسلة بدقة في الفهارس والتدقيق. مرر اسم الشبكة والطابع الزمني في المسار للحصول على رقم الكتلة وطابعها الزمني الدقيق.","ja":"OpenAny REST で任意の UNIX タイムスタンプに最も近いブロック高を検索し、アーカイブノード照会や過去状態監査に活用できます。パスにチェーン名と UNIX タイムスタンプを指定すると、該当ブロック高と正確な時刻を返します。","zh":"通过 OpenAny REST 根据任意 UNIX 时间戳查找指定区块链上最接近的区块高度，方便索引器、归档节点查询与历史审计精确定位链上状态。在路径中传入链名称与数字型 UNIX 时间戳，即可返回匹配的区块高度及其精确时间戳。"},"effectContentHtml":"","executionMode":"sync","id":"1975301c-d271-4002-aa64-997e16655479","includedContentHtml":"","inputs":[{"description":"Chain which you want to get the block from","location":"path","name":"chain","nullable":false,"required":true,"type":"string"},{"description":"UNIX timestamp of the block you are searching for","location":"path","name":"timestamp","nullable":false,"required":true,"type":"integer"}],"logoUrl":"https://api-docs.defillama.com/icons/favicon-96x96.png","method":"GET","name":"DefiLlama — Get the closest block to a timestamp","nameTranslations":{"ar":"DefiLlama — الحصول على أقرب كتلة إلى طابع زمني","ja":"DefiLlama — タイムスタンプに最も近いブロックを取得","zh":"DefiLlama — 获取最接近时间戳的区块"},"overviewHtml":"\u003ch2\u003eDefiLlama Closest Block API\u003c/h2\u003e\n\u003cp\u003eProvide a blockchain name in \u003ccode\u003echain\u003c/code\u003e (such as \u003ccode\u003eethereum\u003c/code\u003e) and a numeric UNIX \u003ccode\u003etimestamp\u003c/code\u003e in seconds. The response returns the closest block \u003ccode\u003eheight\u003c/code\u003e and its exact \u003ccode\u003etimestamp\u003c/code\u003e.\u003c/p\u003e\n\u003ch2\u003eQuick Facts\u003c/h2\u003e\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eFact\u003c/th\u003e\n\u003cth\u003eValue\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eAccess\u003c/td\u003e\n\u003ctd\u003eOpenAny REST\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eAuthentication\u003c/td\u003e\n\u003ctd\u003eOpenAny API key in the Authorization header\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eCore inputs\u003c/td\u003e\n\u003ctd\u003eRequired path parameters: chain (blockchain name, e.g. ethereum) and timestamp (integer UNIX seconds).\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eSelected implementation\u003c/td\u003e\n\u003ctd\u003edefillama · DefiLlama — Get the closest block to a timestamp\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eBilling\u003c/td\u003e\n\u003ctd\u003eSee the pricing area for the selected implementation and request options\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003ch2\u003eWhat You Can Build\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cstrong\u003ePin archive-node eth_call queries\u003c/strong\u003e: Convert a calendar date into a block height before reading historical ERC-20 balances.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eAlign governance snapshots\u003c/strong\u003e: Verify which block height corresponds to a proposal start or end timestamp.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ePair blocks with historical prices\u003c/strong\u003e: Use the resolved block timestamp with the Historical Token Prices API for exact valuation.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2\u003eReturned Data\u003c/h2\u003e\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eField\u003c/th\u003e\n\u003cth\u003eMeaning\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003eheight\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eBlock number closest to the requested UNIX timestamp\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003etimestamp\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eExact UNIX timestamp of the matched block\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003ch2\u003eQuick Start\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eSet OPENANY_API_KEY to your OpenAny API key.\u003c/li\u003e\n\u003cli\u003eReview the selected implementation and pricing, then adapt the request below to your target.\u003c/li\u003e\n\u003cli\u003eCheck the HTTP response and business result before reading optional fields.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cpre\u003e\u003ccode class=\"language-bash\"\u003ecurl --request GET --get \\\n  https://api.openany.si/v1/agent-apis/defillama/block/ethereum/1603964988 \\\n  -H \u0026#34;Authorization: Bearer ${OPENANY_API_KEY}\u0026#34;\n\u003c/code\u003e\u003c/pre\u003e\n\u003ch2\u003eRequest and Response Examples\u003c/h2\u003e\n\u003cp\u003eThe response example is a documentation reference and may be abbreviated. The documented request is a calling template; use the published contract and returned response for the selected implementation.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://openany.si/api/v1/agent-apis/1975301c-d271-4002-aa64-997e16655479\"\u003ePublished DefiLlama Closest Block API implementation contract\u003c/a\u003e.\u003c/p\u003e\n\u003ch2\u003ePricing and Billing\u003c/h2\u003e\n\u003cp\u003eThe pricing area reflects the selected API implementation. Review its billing unit and any request-dependent rules before calling; a source service\u0026#39;s public availability does not determine OpenAny billing.\u003c/p\u003e\n\u003ch2\u003eFrequently Asked Questions\u003c/h2\u003e\n\u003ch3\u003eWhat format should timestamp be in?\u003c/h3\u003e\n\u003cp\u003ePass an integer UNIX timestamp in seconds (for example, 1603964988).\u003c/p\u003e\n\u003ch3\u003eWhat chain names are accepted?\u003c/h3\u003e\n\u003cp\u003ePass lowercase chain names such as ethereum as shown in the reference request.\u003c/p\u003e\n\u003ch3\u003eWhat fields are returned in the response?\u003c/h3\u003e\n\u003cp\u003eThe response is a compact JSON object containing height (block number) and timestamp (exact UNIX seconds).\u003c/p\u003e\n\u003ch3\u003eWhy can the returned timestamp differ by a few seconds from my input?\u003c/h3\u003e\n\u003cp\u003eBlocks are produced at discrete intervals, so the API returns the exact timestamp of the closest mined block.\u003c/p\u003e\n\u003ch3\u003eDoes this endpoint return transactions or block hashes?\u003c/h3\u003e\n\u003cp\u003eNo. It returns only height and timestamp; pass the height to an RPC or explorer API for full block contents.\u003c/p\u003e\n\u003ch3\u003eCan I look up token prices at the same timestamp?\u003c/h3\u003e\n\u003cp\u003eYes. Pass the timestamp to the DefiLlama Historical Token Prices API.\u003c/p\u003e\n\u003ch2\u003eRelated APIs\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://openany.si/market/apis/defillama/defillama-get-historical-prices-of-tokens-by-contract-address\"\u003eDefiLlama Historical Token Prices API\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://openany.si/market/apis/defillama/defillama-get-historical-prices-for-multiple-tokens-at-multiple-different-timestamps\"\u003eDefiLlama Batch Token Prices API\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://openany.si/market/apis/defillama/defillama-get-current-tvl-of-all-chains\"\u003eDefiLlama All Chains TVL API\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n","pagePath":"/markets/apis/defillama/defillama-get-the-closest-block-to-a-timestamp?offering=1975301c-d271-4002-aa64-997e16655479","providerId":"defillama","publicPath":"/v1/agent-apis/defillama/block/{chain}/{timestamp}","requestContentType":"none","revision":5,"samples":[{"http_status":200,"name":"Official UI example (not runtime verified)","request":{"body":null,"headers":{},"path":{"chain":"ethereum","timestamp":1603964988},"query":{}},"response_body":{"height":11150916,"timestamp":1603964988}}],"seoDescription":"Get DefiLlama Closest Block data via REST or MCP powered by DeFiLlama. Pay per call, no subscription. Ideal for pin archive-node eth_call queries.","updatedAt":"2026-12-03T02:39:13.491Z","usageInstructionsHtml":""}}