---
title: getTokenAccountsByOwner
hideTableOfContents: true
h1: getTokenAccountsByOwner RPC Method
---

Returns all SPL Token accounts by token owner.

<DocSideBySide>

<DocLeftSide>

### Parameters

<Parameter type={"string"} required={true}>
  Pubkey of account delegate to query, as base-58 encoded string
</Parameter>

<Parameter type={"object"} required={true}>

A JSON object with either one of the following fields:

- `mint: <string>` - Pubkey of the specific token Mint to limit accounts to, as
  base-58 encoded string; or
- `programId: <string>` - Pubkey of the Token program that owns the accounts, as
  base-58 encoded string

</Parameter>

<Parameter type={"object"} optional={true}>

Configuration object containing the following fields:

<Field
  name="commitment"
  type="string"
  optional={true}
  href="/docs/rpc/index.mdx#configuring-state-commitment"
/>

<Field name="minContextSlot" type="number" optional={true}>
  The minimum slot that the request can be evaluated at
</Field>

<Field name="dataSlice" type="object" optional={true}>
  Request a slice of the account&apos;s data.

- `length: <usize>` - number of bytes to return
- `offset: <usize>` - byte offset from which to start reading

<Callout type="info">
  Data slicing is only available for `base58`, `base64`, or `base64+zstd`
  encodings.
</Callout>

</Field>

<Field 
  name="encoding"
  type="string"
  optional={true}
  href="/docs/rpc/index.mdx#parsed-responses"
>

Encoding format for Account data

<Values values={["base58", "base64", "base64+zstd", "jsonParsed"]} />

<details>

- `base58` is slow and limited to less than 129 bytes of Account data.
- `base64` will return base64 encoded data for Account data of any size.
- `base64+zstd` compresses the Account data using
  [Zstandard](https://facebook.github.io/zstd/) and base64-encodes the result.
- `jsonParsed` encoding attempts to use program-specific state parsers to return
  more human-readable and explicit account state data.
- If `jsonParsed` is requested but a parser cannot be found, the field falls
  back to `base64` encoding, detectable when the `data` field is type `string`.

</details>

</Field>

</Parameter>

### Result

The result will be an RpcResponse JSON object with `value` equal to an array of
JSON objects, which will contain:

- `pubkey: <string>` - the account Pubkey as base-58 encoded string
- `account: <object>` - a JSON object, with the following sub fields:
  - `lamports: <u64>` - number of lamports assigned to this account, as a u64
  - `owner: <string>` - base-58 encoded Pubkey of the program this account has
    been assigned to
  - `data: <object>` - Token state data associated with the account, either as
    encoded binary data or in JSON format `{<program>: <state>}`
  - `executable: <bool>` - boolean indicating if the account contains a program
    \(and is strictly read-only\)
  - `rentEpoch: <u64>` - the epoch at which this account will next owe rent, as
    u64
  - `space: <u64>` - the data size of the account

When the data is requested with the `jsonParsed` encoding a format similar to
that of the [Token Balances Structure](/docs/rpc/json-structures#token-balances)
can be expected inside the structure, both for the `tokenAmount` and the
`delegatedAmount` - with the latter being an optional object.

</DocLeftSide>

<DocRightSide>

### Code sample

```shell
curl https://api.devnet.solana.com -s -X POST -H "Content-Type: application/json" -d '
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getTokenAccountsByOwner",
    "params": [
      "A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd",
      {
        "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
      },
      {
        "encoding": "jsonParsed"
      }
    ]
  }
'
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": { "apiVersion": "2.0.15", "slot": 341197933 },
    "value": [
      {
        "account": {
          "data": {
            "parsed": {
              "info": {
                "isNative": false,
                "mint": "2cHr7QS3xfuSV8wdxo3ztuF4xbiarF6Nrgx3qpx3HzXR",
                "owner": "A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd",
                "state": "initialized",
                "tokenAmount": {
                  "amount": "420000000000000",
                  "decimals": 6,
                  "uiAmount": 420000000.0,
                  "uiAmountString": "420000000"
                }
              },
              "type": "account"
            },
            "program": "spl-token",
            "space": 165
          },
          "executable": false,
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "rentEpoch": 18446744073709551615,
          "space": 165
        },
        "pubkey": "BGocb4GEpbTFm8UFV2VsDSaBXHELPfAXrvd4vtt8QWrA"
      },
      {
        "account": {
          "data": {
            "parsed": {
              "info": {
                "isNative": false,
                "mint": "4KVSsAtsG8JByKfB2jYWgGwvVR9WcBSUfsqpTSL9c3Jr",
                "owner": "A1TMhSGzQxMr1TboBKtgixKz1sS6REASMxPo1qsyTSJd",
                "state": "initialized",
                "tokenAmount": {
                  "amount": "10000000000000",
                  "decimals": 9,
                  "uiAmount": 10000.0,
                  "uiAmountString": "10000"
                }
              },
              "type": "account"
            },
            "program": "spl-token",
            "space": 165
          },
          "executable": false,
          "lamports": 2039280,
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "rentEpoch": 18446744073709551615,
          "space": 165
        },
        "pubkey": "9PwCPoWJ75LSgZeGMubXBdufYMVd66HrcF78QzW6ZHkV"
      }
    ]
  },
  "id": 1
}
```

</DocRightSide>
</DocSideBySide>
