getProgramAccountsV2
Paginated variant of getProgramAccounts. Reach for this when a program owns enough accounts that the single-response version times out or exhausts memory: indexing every token account for a mint, backfilling a DeFi protocol's state, or feeding analytics dashboards from raw on-chain data.
Requests accept the same commitment, encoding, dataSlice, and filters fields as getProgramAccounts, with three additions on the configuration object:
limitbounds a single page to between 1 and 10,000 accounts (default 1,000).paginationKeyis the cursor returned by the previous page; omit it on the first request.changedSinceSlotrestricts the page to accounts written at or after the given slot, so you can keep a downstream index in sync without re-scanning the whole program.
Keep paging while paginationKey is a string. It only turns null once the server has no more accounts to hand out; a page shorter than limit on its own does not mean the walk is finished, because filters can drop accounts server-side before the page ships.
Set withContext: true on the configuration object to receive the wrapped Solana RPC shape: a context object (with at minimum the slot the node evaluated the request at, plus apiVersion when the node reports one) beside a value payload holding accounts and paginationKey. Leave withContext unset or false and those two fields are returned directly on result with no context sibling. Every other aspect of the response is identical between the two shapes.
Path Parameters
docs-demoFor higher throughput, create your own API key
Request
The Pubkey of the program.
Optional configuration object. Accepts every field getProgramAccounts accepts, with the pagination and incremental-update fields (limit, paginationKey, changedSinceSlot) layered on top.
Responses
200
A page of accounts (up to limit) alongside the cursor for the next request. When the request sets withContext: true, the same page is placed inside a {context, value} envelope instead of being returned directly on result.
Shape of the result object. With withContext unset or false, the page's accounts and paginationKey are returned at the top level. With withContext: true, the same page is placed under value, and a context sibling carries the slot the node used to build the response.