TriportRPC

getTokenAccountsByDelegate

POSThttps://api.triport.io

Returns all SPL Token accounts that have approved a given delegate, filtered by mint or by token program.

Solanasol_read_rpcfree+ — 20 rps (free) / 60 rps (basic) / 200 rps (pro) / 600 rps (business), with burst

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
Public key of the delegate to query for. Must match ^[1-9A-HJ-NP-Za-km-z]{32,44}$.
filterobject (TokenAccountsFilter)required
Exactly one of mint or programId (see below).
configobject (GetTokenAccountsConfig)optional
Optional configuration object (see below).
filter (TokenAccountsFilter)object
mintstring (base-58 Pubkey)
Restrict results to token accounts of this specific mint.
programIdstring (base-58 Pubkey)
Restrict results to accounts owned by this token program (e.g. TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA).
config (GetTokenAccountsConfig)object
encodingstringoptional
One of base58, base64, base64+zstd, jsonParsed. Use jsonParsed for a decoded token-account object. base58 is limited to account data under 129 bytes.
commitmentstringoptional
Confirmation level: processed, confirmed, or finalized.
dataSliceobjectoptional
Limits each returned account's data to a byte slice: { "offset": <integer>, "length": <integer> }. Only valid with the binary encodings.
minContextSlotintegeroptional
Minimum slot the request must be evaluated at. The request fails if the node has not yet reached this slot.

Response

Response fields

The result is a TokenAccountsResponse: an RpcContext plus a value array of { pubkey, account } pairs.

FieldTypeDescription
context.slotintegerSlot at which all accounts were evaluated.
context.apiVersionstringVersion of the RPC node that served the request.
valuearrayOne entry per matching token account. Empty if the delegate has no approved accounts under the filter.
value[i].pubkeystring (base-58)Address of the token account.
value[i].accountobject (AccountInfo)The account state (see below).
value[i].account.lamportsintegerBalance of the account in lamports.
value[i].account.ownerstring (base-58)Public key of the program that owns the account (the token program).
value[i].account.executablebooleanWhether the account holds a loaded program (always false for token accounts).
value[i].account.rentEpochintegerEpoch at which this account will next owe rent (u64).
value[i].account.spaceintegerSize of the account data in bytes.
value[i].account.dataobject | arrayAccount 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).

CodeHTTPMeaningWhen it happens
-32602400Invalid paramsdelegate 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).
-32002403Tier insufficientAPI key's tier/scope does not include sol_read_rpc.
-32003429Rate limit exceededMore than your tier's sustained RPS (with burst) was sent. Honour the Retry-After header.
-32601404Method not foundMethod 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 filter object must carry either mint or programId, not both and not neither. Use mint to scope to a single token; use programId (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, jsonParsed decodes the layout into mint, owner, delegate, delegatedAmount, and tokenAmount, which is far easier to work with than raw bytes. Binary encodings (base64, base64+zstd) return the account as a [data, encoding] tuple; base58 only 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 confirmed or processed for lower latency when you can tolerate possible rollbacks; finalized is the safest choice for settled state.
  • Related methods: getTokenAccountsByOwner (by owner), getTokenLargestAccounts, and getAccountInfo (a single account by its address).