getProgramAccounts
Last updated:
getProgramAccounts returns every account whose owner is the supplied
programId. It is the canonical way to enumerate program state — for example,
all token accounts of a mint, all open orders on a market, or all PDAs created
by your own program.
This is a heavy method (sol_read_rpc_heavy category) and is rate-limited
far more strictly than standard read RPC: just 2 rps on the free tier, up to
80 rps on business. A single unfiltered call can scan a very large account set,
so always narrow the result with filters (a memcmp byte match and/or a
dataSize match) and request only the bytes you need with dataSlice. Treat
this method as expensive and cache its results where you can.
By default the result is a plain array of ProgramAccount objects. Set
withContext: true to wrap the array in an RpcContext envelope ({ context, value }), which is useful when you need the slot the result was evaluated at.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| programId | Pubkey | Yes | |
| config | GetProgramAccountsConfig | No |
Returns
| Field | Type |
|---|---|
| result | array |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"getProgramAccounts","params":["<programId>","<config>"],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "getProgramAccounts",
"params": [
"<programId>",
"<config>"
],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"getProgramAccounts","params":["<programId>","<config>"],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet, devnet, testnet.
- Credit cost: 5 per call.
FAQ
- What does getProgramAccounts do?
- Returns all accounts owned by a given Solana program, optionally narrowed by data-size and memcmp filters.
- How many credits does getProgramAccounts cost?
- getProgramAccounts costs 5 credit(s) per call on Triport by default.
- Is getProgramAccounts available over WebSocket?
- getProgramAccounts is an HTTP JSON-RPC method.