getBlocks
https://api.triport.io/v1/solReturns the list of confirmed block slots between two slots on the Solana ledger.
getBlocks returns an array of slot numbers for every confirmed block
between startSlot and endSlot (inclusive). It is the discovery counterpart
to getBlock: 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
JSON-RPC params is a positional array: [startSlot, endSlot?, config?].
startSlotinteger (u64)requiredendSlotinteger (u64)optionalstartSlot and no more than 500,000 slots above it.configobjectoptionalcommitmentstringoptionalconfirmed or finalized. processed is not supported for this method. Defaults to finalized.minContextSlotintegeroptionalResponse
The result is a flat array of the confirmed slot numbers in the range. Here the scanned range was 348392035–348392041 (7 slots) but only 5 produced a block — the gaps are skipped slots.
resultarray of integer (u64)[startSlot, endSlot], ascending. Empty if no slot in the range produced a block.Errors
Errors are returned in the standard JSON-RPC error envelope. See the shared errors reference for the full envelope shape and shared codes.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | startSlot is missing or not an integer, endSlot < startSlot, the range exceeds 500,000 slots, or commitment: "processed" was passed. |
-32002 | Tier insufficient | Method called below its required tier (not applicable here — getBlocks is free+). |
-32003 | Rate limited | More than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600); also surfaced as HTTP 429 with Retry-After. |
401 | Unauthorized | Missing or invalid Authorization: Bearer key. |
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/sol", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlocks",
params: [348392035, 348392041, { commitment: "finalized" }],
}),
});
const { result: slots } = await res.json();
console.log(`${slots.length} blocks produced in range; first=${slots[0]}`);TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY });
const slots = await client.solana.getBlocks(348392035, 348392041, {
commitment: "finalized",
});
console.log(`Confirmed block slots: ${slots.join(", ")}`);Python (triport-sdk)
import os
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
slots = client.solana.get_blocks(
348392035,
348392041,
commitment="finalized",
)
print(f"{len(slots)} confirmed block slots in range")
for slot in slots:
print(slot)Notes
processedis not a valid commitment here — useconfirmedorfinalized. Passingprocessedyields an invalid-params error.- Max range is 500,000 slots. To scan a longer history, loop in windows:
call
getBlocks(start, start + 500_000), then advancestartto one past the last returned slot. endSlotis optional. Omit it to scan fromstartSlotup to the current slot — but mind the 500,000-slot ceiling relative tostartSlot.- Gaps are expected. The returned array skips slots that produced no block; do not assume consecutive values.
- Related methods:
getBlockto fetch each slot's contents,getBlockTimeto map a slot to a wall-clock time,getBlockProductionfor production stats, andgetSlotfor the slot the cluster has currently reached.