getTokenAccountsByOwnerV2
https://api.triport.ioEnhanced, paginated version of `getTokenAccountsByOwner` that returns the SPL token accounts owned by a given address.
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 is intended to add cursor-based pagination so that 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 tier 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 allowances.
Parameters
JSON-RPC positional parameters (intended contract — subject to change at api.2.2+):
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
The finalized result is expected to follow the token-account shape used by
getTokenAccountsByOwner — a context slot plus a value array of
{ pubkey, account } entries — with an added pagination cursor:
result.context.slotintegerresult.valuearrayresult.value[].pubkeystringresult.value[].accountobjectlamports, owner, data, executable, rentEpoch, space.result.value[].account.dataobject/stringconfig.encoding (object when jsonParsed).result.paginationKeystring | nullnull when there are no further results (V2 addition).Errors
| 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 required for the requested allowance. |
429 | Rate limited | You exceeded the requests-per-second allowance for your tier (RPS + burst; there is no daily quota). |
-32601 | Method not found | The method is unavailable on the connected spec version. |
-32602 | Invalid params | Parameters did not match the (finalized) schema — 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://api.triport.io", {
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: [
"4Nd1mYpQ8Z3vR2sK9bXcW7gH5fT6jL1aP0eU8nQ2dVx",
{ mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
{ encoding: "jsonParsed", limit: 100 },
],
}),
});
const { result } = await res.json();
console.log(result.value);TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY! });
// Scaffold method: result is typed as `unknown` until the api.2.2+ schema ships.
const result = await client.solana.rpc("getTokenAccountsByOwnerV2", [
"4Nd1mYpQ8Z3vR2sK9bXcW7gH5fT6jL1aP0eU8nQ2dVx",
{ mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
{ encoding: "jsonParsed", limit: 100 },
]);
console.log(result);Python (triport-sdk)
import os
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
result = client.solana.rpc(
"getTokenAccountsByOwnerV2",
[
"4Nd1mYpQ8Z3vR2sK9bXcW7gH5fT6jL1aP0eU8nQ2dVx",
{"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"},
{"encoding": "jsonParsed", "limit": 100},
],
)
print(result)Notes
- Scaffold status: params and result are deferred to spec api.2.2 / 2.3 / 2.4. Pin your client to a spec version and re-check this page when the finalized schema ships before depending on specific field names.
- Tier: available on the free tier 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: the V2 enhancement is expected to expose
limit/paginationKeyfor cursor-based paging; keep requesting pages untilpaginationKeycomes backnull. - Related methods:
getTokenAccountsByOwner(the non-paginated original),getTokenAccountBalance, and the DAS-indexedgetTokenAccounts.