TriportRPC

getBlocks

Last updated:

`getBlocks` returns an array of slot numbers for every **confirmed block** between `startSlot` and `endSlot` (inclusive). It is the discovery counterpart to [`getBlock`](./getBlock.md): use it to enumerate which slots actually produced a block over a range, then fetch each one's contents individually.

Not every slot has a block — slots can be skipped — so the returned array is typically shorter than `endSlot - startSlot + 1`. Use the array length and its values to drive an indexing loop without probing skipped slots one at a time.

If `endSlot` is omitted it defaults to the current slot. The range is bounded: `endSlot` may be at most **500,000 slots** greater than `startSlot`. Requesting a wider range returns an invalid-params error — page through large histories in ≤500,000-slot windows.

Parameters

getBlocks parameters
NameTypeRequiredDescription
startSlotSlotYes
endSlotSlotNo
configCommitmentConfigNo

Returns

getBlocks return value
FieldType
resultarray

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":["<startSlot>","<endSlot>","<config>"]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "getBlocks",
  "params": [
    "<startSlot>",
    "<endSlot>",
    "<config>"
  ],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"getBlocks","params":["<startSlot>","<endSlot>","<config>"],"jsonrpc":"2.0"})
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet, devnet, testnet.
  3. Credit cost: 1 per call.

FAQ

What does getBlocks do?
Returns the list of confirmed block slots between two slots on the Solana ledger.
How many credits does getBlocks cost?
getBlocks costs 1 credit(s) per call on Triport by default.
Is getBlocks available over WebSocket?
getBlocks is an HTTP JSON-RPC method.