Mainly

List program accounts

Query all accounts owned by a program, with filters and real pagination.

GET /programs/{programId}/accounts

A program's state lives in the accounts it owns — every token balance is an account owned by the Token program, every DEX position an account owned by the DEX. This endpoint queries them with filters and cursor pagination, taming raw RPC's most notorious call (getProgramAccounts: unpaginated, prone to multi-gigabyte responses, and separately rate-limited by every provider).

Parameters

ParameterInTypeRequiredDescription
programIdpathstringYesThe owning program's address.
sizequerynumberNoOnly accounts whose data is exactly this many bytes.
matchquerystringNoRepeatable. {offset}:{base58Bytes} — only accounts whose data contains these bytes at this offset.
limitquerynumberNo1–500, default 100.
cursorquerystringNoPagination cursor.

Always filter. Popular programs own tens of millions of accounts. An unfiltered query against the Token program will page forever and burn your rate limit. If you find yourself listing token accounts by owner or mint, use wallet tokens or token holders instead — they exist so you don't need raw filters.

Example

Find a specific wallet's token accounts by raw query (offset 32 of a token account's data is its owner field, and token accounts are exactly 165 bytes):

curl "https://api.sarg.am/v1/solana/programs/TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA/accounts?size=165&match=32:9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM&limit=2" \
  -H "Authorization: Bearer $MAINLY_API_KEY"
{
  "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
  "items": [
    {
      "address": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
      "lamports": 2039280,
      "sol": 0.00203928,
      "space": 165,
      "data": {
        "format": "parsed",
        "program": "spl-token",
        "parsed": {
          "type": "account",
          "info": {
            "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
            "owner": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
            "tokenAmount": { "raw": "42000000", "decimals": 6, "ui": 42.0, "uiString": "42" },
            "state": "initialized"
          }
        }
      }
    }
  ],
  "nextCursor": null
}

Items use the same data decoding as Get an account — parsed JSON for known programs, plain base64 otherwise.

Errors

codeWhen
invalid_addressThe path parameter isn't valid base58.
invalid_parameterA match filter isn't in offset:base58 form, or size is out of range.
not_foundThe address isn't a program.

Under the hood

Replaces getProgramAccounts / getProgramAccountsV2 with their dataSize/memcmp filter objects, encoding options, and unbounded response sizes.

On this page