Beta release: Please note
getProgramAccountsV2
is available for early use. Contact support to report any issues you experience.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.
New Features in V2:
- Cursor-based pagination: Configure limits from 1 to 10,000 accounts per request
- Incremental updates: Use
changedSinceSlot
to fetch only recently modified accounts - Better performance: Prevents timeouts and reduces memory usage for large datasets
- Backward compatibility: Supports all existing
getProgramAccounts
parameters
Key Benefits
Scalable Queries
Handle programs with millions of accounts by paginating through results efficiently
Real-time Sync
Use
changedSinceSlot
for incremental updates and real-time data synchronizationPrevent Timeouts
Large queries that previously timed out now work reliably with pagination
Memory Efficient
Process data in chunks instead of loading everything into memory at once
Pagination Best Practices
Important Pagination Behavior: End of pagination is only indicated when no accounts are returned. The API may return fewer accounts than your limit due to filtering - always continue pagination until
paginationKey
is null
.Basic Pagination Pattern
Incremental Updates
Performance Tips
Optimal Limit Size: For most use cases, a limit of 1,000-5,000 accounts per request provides the best balance of performance and reliability.
- Start with smaller limits (1000) and increase based on your network performance
- Use appropriate encoding:
jsonParsed
for convenience,base64
for performance - Apply filters to reduce the dataset size before pagination
- Store
paginationKey
to resume queries if interrupted - Monitor response times and adjust limits accordingly
Migration from getProgramAccounts
Migrating from the original method is straightforward - simply replace the method name and add pagination parameters:Related Methods
getProgramAccounts
Original method without pagination
getTokenAccountsByOwnerV2
V2 method for token account queries
Authorizations
Body
application/json
The JSON-RPC protocol version.
Available options:
2.0
Example:
"2.0"
A unique identifier for the request.
Example:
"1"
The name of the RPC method to invoke.
Available options:
getProgramAccountsV2
Example:
"getProgramAccountsV2"
Parameters for the enhanced paginated method.