# getTokenAccountBalance

> Returns the token balance of a single SPL Token or Token-2022 account.

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

`getTokenAccountBalance` returns a token account's balance as a raw integer and pre-divided by the mint's decimals. It only accepts a token account address; a wallet address returns an error, since a wallet's tokens live in its associated token accounts.

With only a wallet address and mint, `getTokenAccountsByOwner` locates the token account first; its result also carries the balance directly, detailed in Notes.

- 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: All plans
- Rate limits: Free 5/s · Operator 50/s · Blade Runner 200/s · Nexus 500/s

## Parameters

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

- `pubkey` (string, required): Address of the token account to check, base-58 encoded.
- `config` (object, optional): Commitment configuration.
  - `commitment` (string, optional, one of `finalized`, `confirmed`, `processed`, default `"finalized"`): Bank state to read the balance from.

## Result

- `result` (object, optional): The token amount, wrapped with context.
  - `context` (object, required)
    - `slot` (integer, optional)
    - `apiVersion` (string, optional)
  - `value` (object, required)
    - `amount` (string, required): Raw token amount in the mint's smallest unit, as a string (can exceed safe JS integer range).
    - `decimals` (integer, required): Number of decimal places the mint uses.
    - `uiAmount` (number | null, optional): Amount divided by 10^decimals, as a float. Deprecated in favor of uiAmountString for anything precision-sensitive.
    - `uiAmountString` (string, required): Amount divided by 10^decimals, as an exact decimal string.

## Example: Get a USDC token account's balance

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": "getTokenAccountBalance",
    "params": ["Gwu5KZVYZpSHuPgKb3ypEVgUTpp2kU5jSnPdSo3N23kS"]
  }'
```

Response:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "4.3.0-rc.0",
      "slot": 447947266
    },
    "value": {
      "amount": "6321160855",
      "decimals": 6,
      "uiAmount": 6321.160855,
      "uiAmountString": "6321.160855"
    }
  },
  "id": 1
}
```

## Notes

- `uiAmountString` avoids the precision `uiAmount` can lose, as a float, on tokens with many decimals or large balances.
- This errors if the address is not a token account, for example a wallet or mint address.

