Skip to content
Alchemy Logo

getTokenAccountsByOwnerV2

POST
/{apiKey}
CUs10

Paginated variant of getTokenAccountsByOwner. Reach for this when a wallet holds enough token accounts that the single-response version times out or runs into memory limits: indexing every SPL Token or Token-2022 account for an active wallet, backing a portfolio dashboard, or keeping a downstream cache aligned with recent on-chain changes.

Requests accept the same commitment, minContextSlot, encoding, and dataSlice fields as getTokenAccountsByOwner, with three additions on the configuration object:

  • limit bounds a single page to between 1 and 10,000 token accounts (default 1,000).
  • paginationKey is the base-58 cursor returned by the previous page; omit it on the first request.
  • changedSinceSlot restricts the page to token accounts written at or after the given slot, so you can keep a downstream index in sync without re-scanning the wallet's full holdings.

The filter requirement carries over from V1: supply either a mint (specific SPL Token or Token-2022 mint) or a programId (SPL Token or Token-2022 program). Querying every token type for a wallet with no filter is not supported.

Keep paging while paginationKey is a string. It only turns null once the server has no more token 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 value is returned directly as the token-account array with paginationKey on result and no context sibling. Every other aspect of the response is identical between the two shapes.

Path Parameters

stringrequireddefaults to docs-demo

For higher throughput, create your own API key

Request

stringrequired

The Pubkey of the account owner to query.

objectrequired

A filter object containing either the Mint Pubkey or the Token program Pubkey. Supply exactly one; querying every token type for a wallet with no filter is not supported.

objectoptional

Optional configuration object. Accepts every field getTokenAccountsByOwner accepts, with the pagination and incremental-update fields (limit, paginationKey, changedSinceSlot) and the withContext response-shape toggle layered on top.

Responses

200

A page of token 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 accounts renamed to value and given as the token-account array directly. With withContext: true, the same page is placed under value as an object (accounts + paginationKey), and a context sibling carries the slot the node used to build the response.

Was this page helpful?