TriportRPC

getProgramAccountsV2

POSThttps://api.triport.io

Enhanced variant of `getProgramAccounts` for listing every account owned by a program — its full parameter and result schema is still being finalized.

Solanasol_read_rpc_heavyfree+ — **2 rps (free) / 5 rps (basic) / 20 rps (pro) / 80 rps (business)**, with burst

getProgramAccountsV2 is the next-generation form of getProgramAccounts: it returns the accounts owned by a given program Pubkey, with the same filtering and encoding controls, and is designed to handle large result sets more gracefully than the original.

Like its predecessor, this is one of the two heavy Solana read methods (sol_read_rpc_heavy). Scanning all accounts owned by a program is expensive for the node, so it is throttled far more aggressively than ordinary reads — just 2 rps on the free tier, rising to 80 rps on business. Budget your calls accordingly, cache results where you can, and always narrow the scan with filters (a dataSize and/or memcmp filter) rather than fetching every account a program owns.

The precise V2 additions (for example, server-side pagination of large result sets) are defined in the pending api.2.2+ spec and are intentionally not enumerated here to avoid documenting field names that may change. Treat the parameter and response tables below as the inherited getProgramAccounts contract that V2 builds on.

Parameters

Pending finalization (api.2.2+). The V2-specific parameters are not yet published. The table reflects the base getProgramAccounts contract that V2 extends. Positional params array: [programId, config?].

programIdstring (base-58 Pubkey)required
Public key of the owning program to scan. Must match ^[1-9A-HJ-NP-Za-km-z]{32,44}$.
configobjectoptional
Optional configuration object (see below).
config (GetProgramAccountsConfig)object
encodingstringoptional
One of base58, base64, base64+zstd, jsonParsed. Controls how each account's data is returned.
commitmentstringoptional
Confirmation level: processed, confirmed, or finalized.
dataSliceobjectoptional
Limits each account's returned data to a byte window: { "offset": <integer>, "length": <integer> }. Only valid with binary encodings.
filtersarrayoptional
List of filters applied server-side to narrow the result set (see below).
minContextSlotintegeroptional
Minimum slot the request must be evaluated at; the request fails if the node has not reached it.
withContextbooleanoptional
When true, wraps the array of accounts in an RpcContext envelope instead of returning a bare array.
filters entries (AccountFilter)object
dataSizeinteger
Match only accounts whose data is exactly this many bytes.
memcmpobject
Match accounts whose data, at a byte offset, equals the provided bytes ({ "offset": <integer>, "bytes": <string>, "encoding": <string> }).

Response

Pending finalization (api.2.2+). The schema declares the result as an open object. The example below shows the inherited getProgramAccounts shape — an array of ProgramAccount objects (or an RpcContext envelope when withContext: true).

pubkeystring (base-58)
Address of the matched account.
account.lamportsinteger
Balance of the account in lamports.
account.ownerstring (base-58)
Owning program — equals the queried programId.
account.executableboolean
Whether the account holds a loaded program.
account.rentEpochinteger
Epoch at which the account will next owe rent (u64).
account.spaceinteger
Size of the account data in bytes.
account.dataarray | object
Account data. Binary encodings return [<data>, <encoding>]; jsonParsed returns a decoded object (or the binary tuple if no parser matched).

Errors

Errors use the standard JSON-RPC envelope (error.code, error.message, error.data).

CodeHTTPMeaningWhen it happens
-32602400Invalid paramsprogramId is not valid base-58, or config contains an invalid value.
-32002403Tier insufficientAPI key's tier/scope does not include sol_read_rpc_heavy.
-32003429Rate limit exceededMore than your tier's sustained heavy-read RPS (with burst) was sent. Honour the Retry-After header.
-32601404Method not foundMethod name misspelled, or the V2 schema is not yet enabled on your endpoint.

Example rate-limit envelope (note the much lower heavy-tier limit):

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32003,
    "message": "Rate limit exceeded: 2 RPS sustained on sol_read_rpc_heavy (free tier)",
    "data": {
      "current_tier": "free",
      "category": "sol_read_rpc_heavy",
      "limit_rps": 2,
      "burst_capacity": 4,
      "retry_after_sec": 1
    }
  }
}

See the shared errors reference for the full envelope and retry guidance.

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: "getProgramAccountsV2",
    params: [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      {
        encoding: "base64",
        commitment: "finalized",
        filters: [{ dataSize: 165 }],
      },
    ],
  }),
});


const { result } = await res.json();
console.log(`${result.length} accounts`);

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


const accounts = await client.sol.getProgramAccountsV2(
  "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
  { encoding: "base64", commitment: "finalized", filters: [{ dataSize: 165 }] },
);


for (const { pubkey, account } of accounts) {
  console.log(pubkey, account.lamports);
}

Python (triport-sdk)

import os
from triport import Triport


client = Triport(api_key=os.environ["TRIPORT_API_KEY"])


accounts = client.sol.get_program_accounts_v2(
    "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
    encoding="base64",
    commitment="finalized",
    filters=[{"dataSize": 165}],
)


for acct in accounts:
    print(acct.pubkey, acct.account.lamports)

Notes

  • Schema is pending. The complete V2 parameter and result definitions ship in spec api.2.2+. Pin to getProgramAccounts for a fully-specified, stable contract today, and re-check this page once the V2 schema is published.
  • Heavy rate limits. getProgramAccountsV2 shares the sol_read_rpc_heavy budget with getProgramAccounts — only 2 / 5 / 20 / 80 rps by tier. These are an order of magnitude lower than standard reads (20 / 60 / 200 / 600 rps); see rate limits and tiers.
  • Always filter. Use dataSize and memcmp filters to restrict the scan server-side. Unfiltered scans over large programs are slow and burn through your limited heavy-read budget quickly.
  • Related methods: getProgramAccounts (the stable v1), getAccountInfo (single account), and getMultipleAccounts (batch of known addresses).