Balances
This page is also Markdown, for agents: /api/reference/balances.md, and /llms.txt lists every page.
See Balances and holders for how to use them.
balances.get
Section titled “balances.get”HTTP: /balances.
| Param | Description |
|---|---|
account |
Required |
sources |
Required. Any of direct (the account’s own token balances), native (its NEAR, not counting what it has staked) and rhea (its deposits in Rhea) |
tokens |
Only these tokens’ balances |
token_fields |
These token fields of each token held come along. Native NEAR’s are wrap.near’s |
Result:
{ "height": 219969785, "timestamp_millis": 1792003812629, "balances": { "columns": ["token", "source", "balance"], "rows": [["wrap.near", "direct", "2564083907000000000000"], ["near", "native", "1000000000000000000000000"]] }, "unknown": [], "errors": {}, "near_locked_for_storage": "0", "tokens": { "columns": ["account_id", "symbol"], "rows": [["wrap.near", "wNEAR"]] }}- Balances are in the token’s smallest units. Native NEAR is token
near, in yoctoNEAR. Tokens the account held before and has none of now are listed with"0". unknown: tokens held that this API doesn’t know, without their balances.errors:{ "<source>": { "code": "upstream_unavailable", "message": "..." } }for each source that couldn’t be read. The others are there all the same.nativealso reports it for an account that doesn’t exist, like an unfunded implicit account, instead of a"0"balance.near_locked_for_storage: the part of thenativebalance that the account’s storage keeps locked, so it can’t spend it: 10^19 yoctoNEAR for each byte the account takes up, less what it has staked, and"0"for an account of 770 bytes or less. It’s there whennativewas read, andtokensis left out or hasnear.tokens: a table of thetoken_fieldsof the tokens inbalances, only withtoken_fields.
The first time an account is asked for, its direct balances come from FastNEAR, and are then stored and re-checked against RPC in the background. Once RPC has answered for all of them, they come from this project’s own indexed balances, and are re-checked again at most once a day, when the account is asked for. When a re-check doesn’t get an answer for every token, they come from FastNEAR again until a re-check a minute later does.
The indexer only counts what happened since it started, so every balance it starts keeping, like a token an account receives for the first time, is re-checked against RPC too, soon after.
balances.subscribe
Section titled “balances.subscribe”Takes the params of balances.get, and:
| Param | Description |
|---|---|
token_min_change |
With token_fields: thresholds for them |
The result is shaped like balances.get’s. It follows direct and native balances. Each push is:
{ "sub": 1, "height": 219969790, "timestamp_millis": 1792003815000, "balances": { "<token>": "<balance>" }, "set": { ... } }balances: every balance the block changed, after a mint, transfer or burn, gas spent or refunded, or a re-check that corrected it.near_locked_for_storage: with a newnearbalance, as inbalances.get.set: as intokens.subscribe, for the held tokens’token_fields, with every field of a token held for the first time.
Rhea deposits aren’t followed, and the result says so with "not_live": ["rhea"]. A connection can follow up to 100 accounts. If the client falls behind, the subscription ends with too_far_behind: subscribe again.