TriportRPC

getBlocks

POSThttps://api.triport.io/v1/sol

Returns the list of confirmed block slots between two slots on the Solana ledger.

Solanasol_read_rpcfree+ — 20 / 60 / 200 / 600 RPS (free / basic / pro / business)

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)required
First slot of the range to scan.
endSlotinteger (u64)optional
Last slot of the range. Defaults to the current slot. Must be ≥ startSlot and no more than 500,000 slots above it.
configobjectoptional
Optional commitment configuration (see below).
commitmentstringoptional
Commitment level: confirmed or finalized. processed is not supported for this method. Defaults to finalized.
minContextSlotintegeroptional
Minimum slot the request should be evaluated at.

Response

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)
Confirmed block slots in [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.

CodeMeaningWhen it happens
-32602Invalid paramsstartSlot is missing or not an integer, endSlot < startSlot, the range exceeds 500,000 slots, or commitment: "processed" was passed.
-32002Tier insufficientMethod called below its required tier (not applicable here — getBlocks is free+).
-32003Rate limitedMore than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600); also surfaced as HTTP 429 with Retry-After.
401UnauthorizedMissing 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

  • processed is not a valid commitment here — use confirmed or finalized. Passing processed yields 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 advance start to one past the last returned slot.
  • endSlot is optional. Omit it to scan from startSlot up to the current slot — but mind the 500,000-slot ceiling relative to startSlot.
  • Gaps are expected. The returned array skips slots that produced no block; do not assume consecutive values.
  • Related methods: getBlock to fetch each slot's contents, getBlockTime to map a slot to a wall-clock time, getBlockProduction for production stats, and getSlot for the slot the cluster has currently reached.