getTokenAccountsByOwnerV2 — Solana JSON-RPC
Enhanced, paginated version of getTokenAccountsByOwner that returns the SPL token accounts owned by a given address.
https://triport.io/sol- Network
- Solana
- Scope
- sol_read_rpc
- Auth
- x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
- Rate limit
- free+ — 20 / 60 / 200 / 600 RPS sustained · short burst 40 / 120 / 400 / 1200 (free / basic / pro / business); Burst capacity
Endpoint and plans: Solana RPC endpoint.
getTokenAccountsByOwnerV2 returns the SPL token accounts owned by a given
wallet address, filtered by either a specific mint or a token program. It is the
enhanced successor to getTokenAccountsByOwner:
the V2 variant adds cursor-based pagination (limit / paginationKey), so
owners holding large numbers of token accounts can be enumerated reliably
without hitting response-size limits.
Use it when you want to list a wallet's token balances — for example to render a
portfolio view or to find the associated token account for a particular mint.
For a single mint you should still pass a filter so the validator only returns
the relevant accounts rather than the owner's entire token set.
This method is served directly from the validator (not the DAS index), so it is
available on the Free trial and up under the sol_read_rpc category. It is
not one of the heavily throttled sol_read_rpc_heavy methods, so it carries
the standard 20 / 60 / 200 / 600 RPS limits.
Parameters
JSON-RPC positional parameters [owner, filter, config?]:
ownerstring (base-58 pubkey)requiredfilterobjectrequiredmint or programId is expected.filter.mintstring (base-58 pubkey)optionalfilter.programIdstring (base-58 pubkey)optionalconfigobjectoptionalconfig.commitmentstringoptionalprocessed, confirmed, or finalized.config.encodingstringoptionalbase58, base64, base64+zstd, or jsonParsed.config.dataSliceobjectoptional{ offset, length } to return a slice of account data.config.minContextSlotintegeroptionalconfig.limitintegeroptionalconfig.paginationKeystringoptionalResponse
Unlike getTokenAccountsByOwner, whose value is a bare array, V2 returns a
page object under value: the accounts array, the cursor for the next page
and the number of accounts in this page.
result.context.slotintegerresult.value.accountsarrayresult.value.accounts[].pubkeystringresult.value.accounts[].accountobjectlamports, owner, data, executable, rentEpoch, space.result.value.accounts[].account.dataobject/arrayconfig.encoding (object when jsonParsed, [<data>, <encoding>] for binary encodings).result.value.paginationKeystring | nullconfig.paginationKey; null on the last page.result.value.countintegerErrors
| Code | Meaning | When it happens |
|---|---|---|
401 | Unauthorized | Missing or invalid Authorization: Bearer API key. |
403 | Forbidden / tier too low | Your plan is below the tier this method requires. |
429 | Rate limited | You exceeded the requests-per-second limit for your tier (RPS + burst; there is no daily quota). |
403 | Unknown method | Method name misspelled — plain HTTP body {"error":"method_unknown", …}, no JSON-RPC envelope. |
-32602 | Invalid params | Parameters did not match — e.g. missing owner or a filter with neither mint nor programId. |
See the shared errors reference for the full error envelope.
Examples
JavaScript (fetch)
const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getTokenAccountsByOwnerV2",
params: [
"5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
{ mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
{ encoding: "jsonParsed", limit: 100 },
],
}),
});
const { result } = await res.json();
const { accounts, paginationKey } = result.value;
console.log(accounts.length, "accounts; next page:", paginationKey); // null on the last pageNotes
- Beta: published schema not final. The endpoint serves V2 today and the fields above are what it returns; the OpenRPC schema still declares no params and an open result object until spec api.2.2+. Re-check this page when that spec ships.
- Tier: available on the Free trial and up under
sol_read_rpc(20 / 60 / 200 / 600 RPS for free / basic / pro / business). See rate limits and tiers. - Filter required: as with
getTokenAccountsByOwner, supply exactly one offilter.mintorfilter.programId. Usemintto find a single associated token account andprogramId(the SPL Token program) to list all of an owner's token accounts. - Pagination: pass
limit, then send each response'svalue.paginationKeyback asconfig.paginationKey; keep requesting pages until it comes backnull. - Related methods:
getTokenAccountsByOwner(the non-paginated original),getTokenAccountBalance, and the DAS-indexedgetTokenAccounts.