getProgramAccountsV2
https://api.triport.ioEnhanced variant of `getProgramAccounts` for listing every account owned by a program — its full parameter and result schema is still being finalized.
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 inheritedgetProgramAccountscontract that V2 builds on.
Parameters
Pending finalization (
api.2.2+). The V2-specific parameters are not yet published. The table reflects the basegetProgramAccountscontract that V2 extends. Positional params array:[programId, config?].
programIdstring (base-58 Pubkey)required^[1-9A-HJ-NP-Za-km-z]{32,44}$.configobjectoptionalconfig (GetProgramAccountsConfig)objectencodingstringoptionalbase58, base64, base64+zstd, jsonParsed. Controls how each account's data is returned.commitmentstringoptionalprocessed, confirmed, or finalized.dataSliceobjectoptional{ "offset": <integer>, "length": <integer> }. Only valid with binary encodings.filtersarrayoptionalminContextSlotintegeroptionalwithContextbooleanoptionaltrue, wraps the array of accounts in an RpcContext envelope instead of returning a bare array.filters entries (AccountFilter)objectdataSizeintegermemcmpobjectoffset, 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 inheritedgetProgramAccountsshape — an array ofProgramAccountobjects (or anRpcContextenvelope whenwithContext: true).
pubkeystring (base-58)account.lamportsintegeraccount.ownerstring (base-58)programId.account.executablebooleanaccount.rentEpochintegeru64).account.spaceintegeraccount.dataarray | object[<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).
| Code | HTTP | Meaning | When it happens |
|---|---|---|---|
-32602 | 400 | Invalid params | programId is not valid base-58, or config contains an invalid value. |
-32002 | 403 | Tier insufficient | API key's tier/scope does not include sol_read_rpc_heavy. |
-32003 | 429 | Rate limit exceeded | More than your tier's sustained heavy-read RPS (with burst) was sent. Honour the Retry-After header. |
-32601 | 404 | Method not found | Method 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 togetProgramAccountsfor a fully-specified, stable contract today, and re-check this page once the V2 schema is published. - Heavy rate limits.
getProgramAccountsV2shares thesol_read_rpc_heavybudget withgetProgramAccounts— 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
dataSizeandmemcmpfilters 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), andgetMultipleAccounts(batch of known addresses).