getTokenAccountsByDelegate
https://api.triport.ioReturns all SPL Token accounts that have approved a given delegate, filtered by mint or by token program.
getTokenAccountsByDelegate returns every SPL Token account whose delegate
authority has been set to the public key you provide. When a token-account owner
calls approve, they grant a delegate the right to transfer up to a fixed
amount on their behalf; this method enumerates all accounts that have named a
particular delegate.
You must narrow the query with exactly one filter — either a specific mint
(only accounts of that token) or a programId (all accounts owned by that token
program, typically the SPL Token or Token-2022 program). The result is a
positional value array of { pubkey, account } pairs read at a single slot,
so the set is internally consistent.
Use jsonParsed encoding to get a decoded token-account object (mint, owner,
delegate, token amount) instead of raw bytes — this is usually what you want for
displaying delegated balances. This is the delegate-keyed counterpart of
getTokenAccountsByOwner, which keys by the
account owner instead.
Parameters
Positional params array: [delegate, filter, config?].
delegatestring (base-58 Pubkey)required^[1-9A-HJ-NP-Za-km-z]{32,44}$.filterobject (TokenAccountsFilter)requiredmint or programId (see below).configobject (GetTokenAccountsConfig)optionalfilter (TokenAccountsFilter)objectmintstring (base-58 Pubkey)programIdstring (base-58 Pubkey)TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA).config (GetTokenAccountsConfig)objectencodingstringoptionalbase58, base64, base64+zstd, jsonParsed. Use jsonParsed for a decoded token-account object. base58 is limited to account data under 129 bytes.commitmentstringoptionalprocessed, confirmed, or finalized.dataSliceobjectoptional{ "offset": <integer>, "length": <integer> }. Only valid with the binary encodings.minContextSlotintegeroptionalResponse
Response fields
The result is a TokenAccountsResponse: an RpcContext plus a value array
of { pubkey, account } pairs.
| Field | Type | Description |
|---|---|---|
context.slot | integer | Slot at which all accounts were evaluated. |
context.apiVersion | string | Version of the RPC node that served the request. |
value | array | One entry per matching token account. Empty if the delegate has no approved accounts under the filter. |
value[i].pubkey | string (base-58) | Address of the token account. |
value[i].account | object (AccountInfo) | The account state (see below). |
value[i].account.lamports | integer | Balance of the account in lamports. |
value[i].account.owner | string (base-58) | Public key of the program that owns the account (the token program). |
value[i].account.executable | boolean | Whether the account holds a loaded program (always false for token accounts). |
value[i].account.rentEpoch | integer | Epoch at which this account will next owe rent (u64). |
value[i].account.space | integer | Size of the account data in bytes. |
value[i].account.data | object | array | Account data. For jsonParsed: a decoded token-account object. For binary encodings: [<data>, <encoding>]. |
Errors
Errors use the standard JSON-RPC envelope (error.code, error.message,
error.data).
| Code | HTTP | Meaning | When it happens |
|---|---|---|---|
-32602 | 400 | Invalid params | delegate is not valid base-58, the filter is missing or specifies neither/both of mint/programId, or config contains an invalid value (e.g. base58 encoding on data larger than 129 bytes). |
-32002 | 403 | Tier insufficient | API key's tier/scope does not include sol_read_rpc. |
-32003 | 429 | Rate limit exceeded | More than your tier's sustained RPS (with burst) was sent. Honour the Retry-After header. |
-32601 | 404 | Method not found | Method name misspelled or not available on this chain. |
Example rate-limit envelope:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32003,
"message": "Rate limit exceeded: 20 RPS sustained on sol_read_rpc (free tier)",
"data": {
"current_tier": "free",
"category": "sol_read_rpc",
"limit_rps": 20,
"burst_capacity": 40,
"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: "getTokenAccountsByDelegate",
params: [
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA",
{ programId: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
{ encoding: "jsonParsed", commitment: "finalized" },
],
}),
});
const { result } = await res.json();
result.value.forEach(({ pubkey, account }) => {
const info = account.data.parsed.info;
console.log(pubkey, info.mint, info.delegatedAmount.uiAmountString);
});TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const { context, value } = await client.sol.getTokenAccountsByDelegate(
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA",
{ programId: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
{ encoding: "jsonParsed", commitment: "finalized" },
);
console.log(`${value.length} delegated accounts at slot ${context.slot}`);
value.forEach(({ pubkey, account }) => {
const info = account.data.parsed.info;
console.log(pubkey, info.mint, info.delegatedAmount.uiAmountString);
});Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
resp = client.sol.get_token_accounts_by_delegate(
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA",
{"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},
encoding="jsonParsed",
commitment="finalized",
)
print(f"{len(resp.value)} delegated accounts at slot {resp.context.slot}")
for entry in resp.value:
info = entry.account.data["parsed"]["info"]
print(entry.pubkey, info["mint"], info["delegatedAmount"]["uiAmountString"])Notes
- Exactly one filter: the
filterobject must carry eithermintorprogramId, not both and not neither. Usemintto scope to a single token; useprogramId(the SPL Token or Token-2022 program) to enumerate every delegated account across all mints. - Delegate vs. owner: this method matches the token account's delegate
authority, not its owner. To list accounts by their owner instead, use
getTokenAccountsByOwner. - Use
jsonParsed: for token accounts,jsonParseddecodes the layout intomint,owner,delegate,delegatedAmount, andtokenAmount, which is far easier to work with than raw bytes. Binary encodings (base64,base64+zstd) return the account as a[data, encoding]tuple;base58only works for data under 129 bytes. - Consistent snapshot: all accounts are read at the single
context.slot, so the returned set is internally consistent. - Commitment: use
confirmedorprocessedfor lower latency when you can tolerate possible rollbacks;finalizedis the safest choice for settled state. - Related methods:
getTokenAccountsByOwner(by owner),getTokenLargestAccounts, andgetAccountInfo(a single account by its address).