getBlocks — Solana JSON-RPC
Returns the list of confirmed block slots between two slots on the Solana ledger.
https://triport.io/sol- Network
- Solana
- Scope
- sol_read_rpc
- Auth
- x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
- Rate limit
- free+ — 20 / 60 / 200 / 600 RPS sustained · short burst 40 / 120 / 400 / 1200 (free / basic / pro / business); Burst capacity
Endpoint and plans: Solana RPC endpoint.
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. |
429 | Rate limited | More than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600). An HTTP error, not a JSON-RPC one: body {"error":"rate_limited", …} with limit_rps, burst_capacity and retry_after_sec, plus Retry-After and X-RateLimit-Reset headers. |
401 | Unauthorized | Missing or invalid Authorization: Bearer key. |
Examples
JavaScript (fetch)
const res = await fetch("https://triport.io/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]}`);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.