MirrorNodeTokenBalanceQuery in the SDK or directly from the Mirror Node REST API. Both are free and do not need an operator account.
Recommended: MirrorNodeTokenBalanceQuery
MirrorNodeTokenBalanceQuery reads an account’s token relationships from the Mirror Node REST API (GET /api/v1/accounts/{id}/tokens) through the SDK’s query interface. It is the SDK replacement for the token balances that AccountBalanceQuery used to return. For HBAR balances, use MirrorNodeAccountBalanceQuery.
- Free: No query payment and no operator key signing.
- Smallest unit: For fungible tokens,
balanceis in the token’s smallest denomination. Divide by 10decimals to get the display amount: abalanceof1234withdecimalsof2is12.34tokens. For NFT collections,balanceis the number of NFTs the account holds. - Flexible account references:
setAccountIdaccepts0.0.<num>, an EVM address (0x...), or a contract ID. The mirror node resolves all of them.
Basic usage
List every token an account holds (Go)
In Go, leaveSetTokenID unset to read all of the account’s token relationships, up to 100 per page. Follow the Next cursor until it is empty:
In the JavaScript SDK,
MirrorNodeTokenBalanceQuery shipped as a single-token query before the cross-SDK design (sdk-collaboration-hub#281) was final. That design is still under review, and the SDK notes that the query’s shape may change once it is accepted, so check the release notes when you upgrade.Behavior by SDK
The three SDKs report a missing token relationship and an unknown account differently:Mirror Node REST API
The SDK query calls this endpoint, and you can call it directly from any language, including Rust. Addtoken.id to return a single token, or leave it out to list every token the account holds:
- The response lists only tokens the account is associated with. An unassociated token returns an empty
tokensarray. - An unknown account returns HTTP 404.
- When listing every token, follow
links.nextuntil it isnull.
SDK versions
MirrorNodeTokenBalanceQuery is available in:
- JavaScript (
@hiero-ledger/sdk): v2.89.0+ - Java (
com.hedera.hashgraph:sdk): v2.78.0+ - Go (
github.com/hiero-ledger/hiero-sdk-go/v2): v2.85.0+ - Rust: not available. Use the Mirror Node REST API.
HBAR balances
MirrorNodeTokenBalanceQuery returns token balances only. To read an account’s HBAR balance, see Get account balance.