Skip to main content

qn_getBlocksInTimestampRange RPC Method

Retrieves all blocks within a specified Unix timestamp range, allowing you to query historical blocks in a defined time window. The response can be paginated to efficiently handle large sets of data, making it useful for detailed analysis across extended time periods.

Updated on
Nov 6, 2024

qn_getBlocksInTimestampRange RPC Method

Please note that this RPC method requires the Block Timestamp Lookup add-on enabled on your QuickNode endpoint. This method is available for mainnet only.

Parameters

startTimestamp
integer
REQUIRED
The Unix timestamp (in seconds) marking the start of the desired time range
endTimestamp
integer
REQUIRED
The Unix timestamp (in seconds) marking the end of the desired time range
pageSize
integer
(Optional) Defines how many blocks to return per page. The default value is 100, with a maximum of 1000
lastTimestamp
integer
(Optional) The timestamp of the last block from the previous page, used to paginate through large result sets
lastBlockNumber
integer
(Optional) The block number of the last block from the previous page, used in conjunction with lastTimestamp for pagination

Returns

result
object
The result object which contains the following fields:
blocks
array
An array that contains the list of block objects that fall within the specified timestamp range. Each object represents a block and contains the following fields:
blockNumber
integer
The unique number of the block on the blockchain
network
string
The blockchain network on which the block exists
timestamp
integer
The Unix timestamp (in seconds) representing when the block was created
pagination
object
The pagination object which contains the following fields:
hasNextPage
boolean
A boolean value that indicates whether there are more pages of results to retrieve. If true, it means there are additional blocks that fall within the specified timestamp range but were not included in the current response due to the pageSize limit
nextPageParams
object
The nextPageParams object which contains the following fields:
lastBlockNumber
integer
The block number of the last block in the current page
lastTimestamp
integer
The timestamp of the last block in the current page
pageSize
integer
The number of blocks that were returned in the current response
Request
1
curl --location 'https://docs-demo.btc.quiknode.pro/' \
2
--header 'Content-Type: application/json' \
3
--data '{
4
"method": "qn_getBlocksInTimestampRange",
5
"params": {
6
"startTimestamp": 1730000000,
7
"endTimestamp": 1730000100,
8
"pageSize": 5
9
}
10
}'
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free