# getTokenAccountsByOwner

> Returns every token account owned by a given wallet, optionally filtered to one mint or token program.

Source: https://docs.constant-k.com/rpc/http/gettokenaccountsbyowner/

`getTokenAccountsByOwner` returns every SPL Token or Token-2022 account a wallet controls, narrowed by either a specific `mint` or a `programId`; no single call lists every mint a wallet holds.

- Transport: HTTP, JSON-RPC 2.0 `POST` to `https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY` (New York) or `https://rpc-frankfurt.constant-k.com/?api-key=YOUR_API_KEY` (Frankfurt) or `https://rpc-amsterdam.constant-k.com/?api-key=YOUR_API_KEY` (Amsterdam). The key also works as an `x-api-key` header.
- Category: Tokens
- Availability: Operator and above
- Rate limits: Free not available · Operator 5/s · Blade Runner 10/s · Nexus 30/s

## Parameters

`params` is a positional JSON array, in this order:

- `owner` (string, required): Wallet address that owns the token accounts, base-58 encoded.
- `filter` (object, required): Exactly one of `mint` or `programId` — the two are mutually exclusive.
  - `option 1` (object, optional)
    - `mint` (string, required): Restricts results to token accounts for this specific mint, base-58 encoded.
  - `option 2` (object, optional)
    - `programId` (string, required): Restricts results to token accounts owned by this token program (the classic SPL Token program or Token-2022), base-58 encoded.
- `config` (object, optional): Optional configuration.
  - `commitment` (string, optional, one of `finalized`, `confirmed`, `processed`, default `"finalized"`): Bank state to read the accounts from.
  - `encoding` (string, optional, one of `base58`, `base64`, `base64+zstd`, `jsonParsed`, default `"base58"`): How to encode each account's `data`. `jsonParsed` decodes the token account fields directly and suits most cases here.
  - `dataSlice` (object, optional): Returns only a byte range of each account's `data`. Not valid with `jsonParsed`.
    - `offset` (integer, required)
    - `length` (integer, required)
  - `minContextSlot` (integer, optional): Minimum slot the node must have processed before answering.

## Result

- `result` (object, optional): Matching token accounts, wrapped with context.
  - `context` (object, required)
    - `slot` (integer, optional)
    - `apiVersion` (string, optional)
  - `value` (object[], required)
    - `pubkey` (string, optional): Token account address, base-58 encoded.
    - `account` (object, optional)
      - `lamports` (integer, optional)
      - `owner` (string, optional): The token program that owns this account (not the wallet that controls its tokens).
      - `executable` (boolean, optional)
      - `rentEpoch` (integer, optional)
      - `space` (integer, optional)
      - `data` (any, optional): Same shape as `getAccountInfo`. With `jsonParsed`, `data.parsed.info` includes `mint`, `owner` (the wallet), `state` and `tokenAmount`.

## Example: Get one wallet's USDC token account

Request:

```bash
curl "https://rpc-newyork.constant-k.com/?api-key=YOUR_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTokenAccountsByOwner",
    "params": [
      "HwfP9khbHJgWwnWB9Ai3DVCe8RWjCJUyYQETMnpxZ6YQ",
      { "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
      { "encoding": "jsonParsed" }
    ]
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 447947271,
      "apiVersion": "4.2.1"
    },
    "value": [
      {
        "pubkey": "Gwu5KZVYZpSHuPgKb3ypEVgUTpp2kU5jSnPdSo3N23kS",
        "account": {
          "data": {
            "parsed": {
              "info": {
                "isNative": false,
                "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                "owner": "HwfP9khbHJgWwnWB9Ai3DVCe8RWjCJUyYQETMnpxZ6YQ",
                "state": "initialized",
                "tokenAmount": {
                  "amount": "6321160855",
                  "decimals": 6,
                  "uiAmount": 6321.160855,
                  "uiAmountString": "6321.160855"
                }
              },
              "type": "account"
            },
            "program": "spl-token",
            "space": 165
          },
          "executable": false,
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "rentEpoch": 18446744073709552000,
          "space": 165
        }
      }
    ]
  },
  "id": 1
}
```

## Notes

- Not available on the Free plan.
- Passing `programId` instead of `mint` returns every token account under that program, potentially many; `mint` scopes the result to a single known token.
- A wallet with no token account for the given mint returns an empty `value` array, not an error and not a null entry.

