getBlocks

The getBlocks method returns a list of confirmed blocks between two specified slot numbers. This method is essential for applications that need to process blockchain data sequentially, implement block scanning functionality, or build comprehensive blockchain indexers.

Unlike fetching individual blocks, this method provides an efficient way to discover which slots actually contain blocks within a range. This is important because Solana slots can be skipped when validators fail to produce blocks, so not every slot number corresponds to an actual block. By using this method, applications can iterate through blocks without attempting to fetch non-existent blocks from skipped slots.

This method is commonly used by blockchain explorers, data indexers, and analytics platforms that need to process historical blockchain data. It's particularly valuable for backfilling data, detecting gaps in local storage, or implementing efficient block synchronization mechanisms. The method supports large ranges but may have practical limits imposed by RPC providers to prevent excessive resource consumption.


Parameters

parameter
type
description
startSlot
number
The start slot, inclusive (u64)
endSlot
number
The end slot, inclusive. Must be no more than 500,000 slots higher than startSlot (optional, defaults to latest confirmed slot)
config
object
Optional configuration object
config.commitment
string
Level of commitment: 'confirmed' or 'finalized' (default: 'finalized'). 'processed' is not supported
Return Object
field
type
description
result
array
Array of slot numbers (u64) representing confirmed blocks in the specified range, sorted in ascending order
Request Example
Request
Response Example
Response

Tip: Notice that some slot numbers may be missing from the result (e.g., 234567893, 234567896, 234567901) indicating skipped slots. The maximum range is typically 500,000 slots. For larger ranges, make multiple requests. Use getBlocksWithLimit if you need a specific number of blocks rather than a range.


Share on
Share on FacebookShare on XShare on LinkedIn
Did you find this page useful?