New: Try Gatekeeper (Beta) for significantly lower latency. Learn More
New: Try Gatekeeper (Beta) for significantly lower latency. Learn More
Enhanced version of getProgramAccounts with cursor-based pagination and changedSinceSlot support for efficiently querying large sets of accounts owned by specific Solana programs with incremental updates.
curl --request POST \
--url 'https://mainnet.helius-rpc.com/?api-key=' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": "1",
"method": "getProgramAccountsV2",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{
"encoding": "base64",
"limit": 1000
}
]
}
'{
"jsonrpc": "2.0",
"id": "1",
"result": {
"accounts": [
{
"pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY",
"account": {
"lamports": 15298080,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"data": [
"2R9jLfiAQ9bgdcw6h8s44439",
"base64"
],
"executable": false,
"rentEpoch": 28,
"space": 165
}
}
],
"paginationKey": "8WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"totalResults": 25000
}
}Documentation Index
Fetch the complete documentation index at: https://helius-add-sendbundle-api-docs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
getProgramAccountsV2 is an enhanced version of the standard getProgramAccounts method, designed for applications that need to efficiently query large sets of accounts owned by specific Solana programs. This method introduces cursor-based pagination and incremental update capabilities.
changedSinceSlot to fetch only recently modified accountsgetProgramAccounts parameterschangedSinceSlot for incremental updates and real-time data synchronizationpaginationKey is null.let allAccounts = [];
let paginationKey = null;
do {
const response = await fetch(`https://mainnet.helius-rpc.com/?api-key=${API_KEY}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: '1',
method: 'getProgramAccountsV2',
params: [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{
encoding: 'base64',
filters: [{ dataSize: 165 }],
limit: 5000,
...(paginationKey && { paginationKey })
}
]
})
});
const data = await response.json();
allAccounts.push(...data.result.accounts);
paginationKey = data.result.paginationKey;
} while (paginationKey);
// Get only accounts modified since slot 150000000
const incrementalUpdate = await fetch(`https://mainnet.helius-rpc.com/?api-key=${API_KEY}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: '1',
method: 'getProgramAccountsV2',
params: [
programId,
{
encoding: 'jsonParsed',
limit: 1000,
changedSinceSlot: 150000000
}
]
})
});
jsonParsed for convenience, base64 for performancepaginationKey to resume queries if interrupted{
"jsonrpc": "2.0",
"id": "1",
- "method": "getProgramAccounts",
+ "method": "getProgramAccountsV2",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{
"encoding": "base64",
"filters": [{ "dataSize": 165 }],
+ "limit": 5000
}
]
}
confirmedfinalizedprocessedjsonParsedbase58base64base64+zstdThe JSON-RPC protocol version.
2.0 "2.0"
A unique identifier for the request.
"1"
The name of the RPC method to invoke.
getProgramAccountsV2 "getProgramAccountsV2"
Parameters for the enhanced paginated method.
The Solana program public key (address) to query accounts for, as a base-58 encoded string.
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
Was this page helpful?
curl --request POST \
--url 'https://mainnet.helius-rpc.com/?api-key=' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": "1",
"method": "getProgramAccountsV2",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
{
"encoding": "base64",
"limit": 1000
}
]
}
'{
"jsonrpc": "2.0",
"id": "1",
"result": {
"accounts": [
{
"pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY",
"account": {
"lamports": 15298080,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"data": [
"2R9jLfiAQ9bgdcw6h8s44439",
"base64"
],
"executable": false,
"rentEpoch": 28,
"space": 165
}
}
],
"paginationKey": "8WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"totalResults": 25000
}
}