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:
limit bounds a single page to between 1 and 10,000 accounts (default 1,000).
paginationKey is the cursor returned by the previous page; omit it on the first request.
changedSinceSlot restricts 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.