getBlocksWithLimit RPC Method
Please note that for this RPC method, block range limits are set to 5 for Free Trial plans and 1005 for all paid accounts.
Parameters
start_slot
string
REQUIRED
Loading...
limit
string
REQUIRED
Loading...
object
object
Loading...
commitment
string
Loading...
Returns
result
Loading...
Request
curl https://docs-demo.solana-mainnet.quiknode.pro/ \
-X POST \
-H "Content-Type: application/json" \
-d $'
{
"jsonrpc": "2.0",
"id":1,
"method":"getBlocksWithLimit",
"params":[5, 3]
}
'require "uri"
require "json"
require "net/http"
url = URI("https://docs-demo.solana-mainnet.quiknode.pro/")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocksWithLimit",
"params": [
5,
3
]
})
response = https.request(request)
puts response.read_body
import { createSolanaRpc } from "@solana/kit";
(async () => {
const solanaRpc = createSolanaRpc("https://docs-demo.solana-mainnet.quiknode.pro/");
try {
const blocks = await solanaRpc.getBlocksWithLimit(BigInt(5), 3).send();
console.log(blocks);
} catch (error) {
console.error("Error fetching blocks with limit:", error);
}
})();// not currently supported by solanaJS
const axios = require("axios");
(() => {
const config = {
headers: {
"Content-Type": "application/json",
},
};
const data = {
jsonrpc: "2.0",
id: 1,
method: "getBlocksWithLimit",
params: [5, 3],
};
axios
.post("https://docs-demo.solana-mainnet.quiknode.pro/", data, config)
.then(function (response) {
// handle success
console.log(response.data);
})
.catch((err) => {
// handle error
console.log(err);
});
})();
from jsonrpcclient import request, parse, Ok
import logging
import requests
response = requests.post("https://docs-demo.solana-mainnet.quiknode.pro/",json=request("getBlocksWithLimit", params=[5,3]))
parsed = parse(response.json())
if isinstance(parsed, Ok):
print(parsed.result)
else:
logging.error(parsed.message)
use reqwest::header;
use reqwest::Client;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let mut headers = header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse().unwrap());
let client = Client::new();
let json_data = r#"
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlocksWithLimit",
"params": [
5,
3
]
}
"#;
let response = client
.post("https://docs-demo.solana-mainnet.quiknode.pro/")
.headers(headers)
.body(json_data)
.send()
.await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}
Response
{
"jsonrpc": "2.0",
"result": [
5,
6,
7
],
"id": 1
}Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free