alchemy_getBlockByTimestamp
POST
/{apiKey}
Returns the block whose timestamp is closest to the timestamp you pass in. The response is the same block object that eth_getBlockByNumber returns, so you can use it anywhere you would use a block fetched by number.
How the block is chosen
- Closest block: returns the block whose timestamp is nearest to the requested time. This block can be before or after the requested time.
- Ties: if two blocks are equally close, returns the earlier block.
- Clamping: a timestamp after the latest block returns the latest block. A timestamp before the genesis block returns the genesis block.
Timestamp formats
- Unix time in seconds, for example
1700000000. - Unix time in milliseconds, for example
1700000000000. Values of1000000000000or greater are read as milliseconds. - An ISO-8601 date-time string with a time zone, for example
2023-11-14T22:13:20Zor2023-11-14T17:13:20-05:00. Date-only strings and strings without a time zone are rejected.
Supported networks: all EVM networks. Non-EVM networks return an Unsupported method error.
Batch requests are not supported yet. Send each alchemy_getBlockByTimestamp call as its own request. A batch that contains this method returns a -32000 error for each entry.
Path Parameters
stringrequireddefaults to
docs-demoFor higher throughput, create your own API key
Request
objectrequired
An object with the timestamp to look up and whether to include full transaction objects.
Responses
200
The block closest to the requested timestamp, in the same format as eth_getBlockByNumber.
Errors
-32602Invalid params. Returned when `timestamp` is missing, negative, or not in a supported format, or when `params` is not shaped as `[{"timestamp": ..., "includeTransactions": ...}]`.
-32000Server error. Returned for batch requests, which are not supported yet, and when the request can't be completed on the selected network.
Was this page helpful?