Querying Specific Token Balances by Address

·

Overview

Learn how to query balances of specific tokens associated with a blockchain address using Web3 API. This guide provides detailed instructions on request parameters, response formats, and practical examples.


API Endpoint

POST https://web3.okx.com/api/v5/wallet/asset/token-balances-by-address


Request Parameters

ParameterTypeRequiredDescription
addressStringYesBlockchain address to query.
tokenAddressesArrayYesList of token contract addresses (max 20). Includes:
> chainIndexStringYesUnique chain identifier (e.g., 1 for mainnet).
> tokenAddressStringYesToken contract address. Leave empty ("") for mainnet coins. For inscriptions (e.g., BRC-20), use formats like btc-brc20-ordi.
filterStringNo0: Exclude risky airdrop tokens (default). 1: Include all tokens.

Response Parameters

ParameterTypeDescription
tokenAssetsArrayList of token balances.
> chainIndexStringChain identifier.
> tokenAddressStringToken contract address.
> symbolStringToken symbol (e.g., ETH).
> balanceStringToken balance.
> rawBalanceStringRaw token balance (if supported).
> tokenPriceStringUSD price per token.
> tokenTypeString1: Standard token. 2: Inscription.
> transferAmountStringTransferable balance for inscriptions.
> availableAmountStringPending inscription balance.
> isRiskTokenBooleantrue if token is flagged as risky.

Example Request

{
  "address": "0x123...abc",
  "tokenAddresses": [
    {
      "chainIndex": "1",
      "tokenAddress": "0x456...def"
    }
  ],
  "filter": "0"
}

Example Response

{
  "tokenAssets": [
    {
      "chainIndex": "1",
      "tokenAddress": "0x456...def",
      "symbol": "OKT",
      "balance": "10.5",
      "tokenPrice": "25.30",
      "isRiskToken": false
    }
  ]
}

FAQs

1. How many token addresses can I query at once?

The API supports up to 20 token addresses per request.

2. What’s the difference between balance and rawBalance?

3. How do I filter out risky tokens?

Set filter to "0" (default) to exclude tokens flagged as risky airdrops.

👉 Explore advanced Web3 API features

4. Can I query mainnet coin balances?

Yes. Pass an empty string ("") as tokenAddress for the chain’s native coin (e.g., ETH for Ethereum).

5. What formats are required for inscription tokens?

Use structured formats like btc-brc20-ordi for BRC-20 tokens or fbtc_fbrc20_babymusk for FBRC-20.

👉 Need help with token queries?


Key Takeaways