getProgramAccountsV2
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.
Documentation Index
Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
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.
- Cursor-based pagination: Configure limits from 1 to 10,000 accounts per request
- Incremental updates: Use
changedSinceSlotto fetch only recently modified accounts - Better performance: Prevents timeouts and reduces memory usage for large datasets
- Backward compatibility: Supports all existing
getProgramAccountsparameters - Optional
withContext:trueaddsslotandapiVersionunderresult.context; omit orfalseand they are not included
Key Benefits
Scalable Queries
Real-time Sync
changedSinceSlot for incremental updates and real-time data synchronizationPrevent Timeouts
Memory Efficient
Pagination Best Practices
Basic Pagination Pattern
Incremental Updates
Performance Tips
- Start with smaller limits (1000) and increase based on your network performance
- Use appropriate encoding:
jsonParsedfor convenience,base64for performance - Apply filters to reduce the dataset size before pagination
- Store
paginationKeyto resume queries if interrupted - Monitor response times and adjust limits accordingly
withContext (optional)
Boolean on the program config object (params[1]). Only the shape of result changes, not filters, limits, or pagination.
Migration from getProgramAccounts
Migrating from the original method is straightforward - simply replace the method name and add pagination parameters:Related Methods
getProgramAccounts
getTokenAccountsByOwnerV2
Request Parameters
confirmedfinalizedprocessed
true, returns result.context (snapshot metadata: slot, apiVersion) and nests
accounts and paginationKey under result.value. When false or omitted,
those fields appear directly on result (for example result.accounts). Same filters and limits apply.jsonParsedbase58base64base64+zstd
Authorizations
Body
The 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"
Response
Successfully retrieved paginated program accounts.
The JSON-RPC protocol version.
2.0 "2.0"
Identifier matching the request.
"1"
Paginated program accounts. Same fields appear on result when withContext is false or omitted, or under result.value when withContext is true.
- without withContext
- with withContext