getBlocks
Returns a list of confirmed blocks between two slots. The range is inclusive and limited to 500,000 slots. This method is useful for indexers that need to enumerate all confirmed blocks in a range, analytics engines building historical datasets, and services that need to identify gaps in block production.
Parameters
| # | Type | Required | Description |
|---|---|---|---|
| 1 | u64 | Yes | Start slot (inclusive) |
| 2 | u64 | No | End slot (inclusive). Must be no more than 500,000 slots higher than start_slot |
| 3 | object | No | Configuration object |
Configuration object fields:
| Field | Type | Description |
|---|---|---|
commitment | string | Commitment level: confirmed or finalized (default finalized) |
Response
Returns an array:
| Field | Type | Description |
|---|---|---|
result | array[u64] | Array of confirmed slot numbers within the range |
Code Examples
cURL
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocks",
"params": [
166974000, 166974442
]
}'TypeScript
const response = await fetch("http://88.216.36.108:7999", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlocks",
params: [
166974000, 166974442
]
}),
});
const { result } = await response.json();
console.log("Blocks found:", result.length);Python
import requests
response = requests.post("http://88.216.36.108:7999", json={
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocks",
"params": [
166974000, 166974442
]
})
result = response.json()["result"]
print(f"Blocks found: {len(result)}")Rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client.post("http://88.216.36.108:7999")
.json(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocks",
"params": [
166974000_u64, 166974442_u64
]
}))
.send().await?
.text().await?;
println!("{}", res);
Ok(())
}Example Response
{
"jsonrpc": "2.0",
"result": [166974000, 166974001, 166974002, 166974003],
"id": 1
}