TriportRPC

getTokenAccountsByOwnerV2

POSThttps://api.triport.io

Enhanced, paginated version of `getTokenAccountsByOwner` that returns the SPL token accounts owned by a given address.

Solanasol_read_rpcfree+ — 20 / 60 / 200 / 600 RPS (free / basic / pro / business)

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)required
Owner account whose token accounts are returned.
filterobjectrequired
Filter selecting which token accounts to return. Exactly one of mint or programId is expected.
filter.mintstring (base-58 pubkey)optional
Return only accounts holding this specific mint.
filter.programIdstring (base-58 pubkey)optional
Return all accounts owned by this token program (e.g. the SPL Token program).
configobjectoptional
Optional encoding / commitment configuration.
config.commitmentstringoptional
Commitment level: processed, confirmed, or finalized.
config.encodingstringoptional
Account-data encoding: base58, base64, base64+zstd, or jsonParsed.
config.dataSliceobjectoptional
{ offset, length } to return a slice of account data.
config.minContextSlotintegeroptional
Minimum slot at which the request can be evaluated.
config.limitintegeroptional
Maximum number of accounts to return per page (V2 pagination).
config.paginationKeystringoptional
Opaque cursor returned by a prior call to fetch the next page (V2 pagination).

Response

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.slotinteger
Slot at which the data was read.
result.valuearray
List of matching token accounts.
result.value[].pubkeystring
Base-58 address of the token account.
result.value[].accountobject
The decoded account: lamports, owner, data, executable, rentEpoch, space.
result.value[].account.dataobject/string
Account data, encoded per config.encoding (object when jsonParsed).
result.paginationKeystring | null
Cursor for the next page; null when there are no further results (V2 addition).

Errors

CodeMeaningWhen it happens
401UnauthorizedMissing or invalid Authorization: Bearer API key.
403Forbidden / tier too lowYour plan is below the tier required for the requested allowance.
429Rate limitedYou exceeded the requests-per-second allowance for your tier (RPS + burst; there is no daily quota).
-32601Method not foundThe method is unavailable on the connected spec version.
-32602Invalid paramsParameters 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 of filter.mint or filter.programId. Use mint to find a single associated token account and programId (the SPL Token program) to list all of an owner's token accounts.
  • Pagination: the V2 enhancement is expected to expose limit / paginationKey for cursor-based paging; keep requesting pages until paginationKey comes back null.
  • Related methods: getTokenAccountsByOwner (the non-paginated original), getTokenAccountBalance, and the DAS-indexed getTokenAccounts.