> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getTokenAccounts

> List SPL Token and Token-2022 accounts by owner or by mint, with paging, using DAS getTokenAccounts on OrbitFlare.

## Overview

`getTokenAccounts` lists token accounts filtered by owner, by mint, or both. Filter by mint to page through every holder of a token; filter by owner to list a wallet's token accounts. Unlike [getProgramAccounts](/rpc/methods/getProgramAccounts), it pages, so it works for mints with millions of holders.

Accounts with a zero balance are left out unless you set `showZeroBalance`.

## Parameters

Pass at least one of `owner` and `mint`.

<ResponseField name="owner" type="string">
  Owner wallet (base-58). Also accepted as `ownerAddress`.
</ResponseField>

<ResponseField name="mint" type="string">
  Token mint (base-58). Also accepted as `mintAddress`.
</ResponseField>

<ResponseField name="page" type="number">
  Page number, starting at 1. See [Pagination](/das-api/pagination).
</ResponseField>

<ResponseField name="limit" type="number">
  Results per page. Maximum and default 1,000.
</ResponseField>

<ResponseField name="cursor" type="string">
  Cursor from a previous response.
</ResponseField>

<ResponseField name="before" type="string">
  Return accounts before this one.
</ResponseField>

<ResponseField name="after" type="string">
  Return accounts after this one.
</ResponseField>

<ResponseField name="options" type="object">
  [Display options](/das-api/display-options): `showZeroBalance`. Also accepted as `displayOptions`.
</ResponseField>

## Response

<ResponseField name="result" type="object">
  <Expandable title="result fields">
    <ResponseField name="total" type="number">
      Number of accounts in this page.
    </ResponseField>

    <ResponseField name="limit" type="number">
      Page size used.
    </ResponseField>

    <ResponseField name="page" type="number">
      Page number, when paging by page.
    </ResponseField>

    <ResponseField name="cursor" type="string">
      Cursor for the next page, when paging by cursor.
    </ResponseField>

    <ResponseField name="token_accounts" type="array">
      <Expandable title="token account fields">
        <ResponseField name="address" type="string">
          Token account address.
        </ResponseField>

        <ResponseField name="mint" type="string">
          Mint address.
        </ResponseField>

        <ResponseField name="owner" type="string">
          Owner wallet.
        </ResponseField>

        <ResponseField name="amount" type="number">
          Balance in base units.
        </ResponseField>

        <ResponseField name="delegate" type="string | null">
          Delegate, if set.
        </ResponseField>

        <ResponseField name="delegated_amount" type="number">
          Amount the delegate may transfer.
        </ResponseField>

        <ResponseField name="close_authority" type="string | null">
          Close authority, if set.
        </ResponseField>

        <ResponseField name="frozen" type="boolean">
          Whether the account is frozen.
        </ResponseField>

        <ResponseField name="token_extensions" type="object">
          Token-2022 account extensions, when present.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

### Holders of a mint

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenAccounts",
  "params": {
    "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "page": 1,
    "limit": 2
  }
}'
```

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "result": {
    "total": 2,
    "limit": 2,
    "page": 1,
    "token_accounts": [
      {
        "address": "1113odRAP5wXa8n7NFVBG53XrqWeDrViZu5rSiSsVA3",
        "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "owner": "HJNr4feTNiDn59RCL1pYoARXMFoBEQSmAY7R7Cm21z9T",
        "amount": 170812,
        "delegate": null,
        "delegated_amount": 0,
        "close_authority": null,
        "frozen": false
      },
      {
        "address": "11NCSQ2Bm6UZdtDqBeHFcos5eFXT1kJ3jG29qKJCWU",
        "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "owner": "FRPPBdG4sYCH7EnTMeKFSVLsfzfEUo4PQ1wWCUkzzmuv",
        "amount": 1804811,
        "delegate": null,
        "delegated_amount": 0,
        "close_authority": null,
        "frozen": false
      }
    ]
  },
  "id": 1
}
```

### Count every holder of a token

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const RPC_URL = 'https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY';

async function countHolders(mint: string) {
  const owners = new Set<string>();
  let cursor: string | undefined;

  while (true) {
    const response = await fetch(RPC_URL, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getTokenAccounts',
        params: { mint, limit: 1000, cursor },
      }),
    });
    const { result, error } = await response.json();
    if (error) throw new Error(error.message);

    for (const account of result.token_accounts) owners.add(account.owner);
    if (result.token_accounts.length < 1000) break;
    cursor = result.cursor;
  }

  return owners.size;
}
```

## Common Errors

| Code | Message | Solution |
| - | - | - |
| -32602 | Validation Error: Pass 'owner', 'mint' or both (also accepted as 'ownerAddress' and 'mintAddress') | Send `owner`, `mint` or both |
| -32602 | Validation Error: Invalid pubkey ... | Pass valid base-58 addresses |
| -32602 | Pagination Error. Limit should not be greater than 1000. | Use a `limit` of 1,000 or less |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.