Account

Get All Account Balances

Changed on

Get an array of all AccountBalances for all sub-accounts of an AccountIdentifier and the BlockIdentifier at which the balance lookup was performed. This endpoint returns balances for the main account and all associated sub-accounts in a single request, eliminating the need to make multiple individual /account/balance calls.

The BlockIdentifier must always be returned because some consumers of account balance data need to know specifically at which block the balance was calculated to compare balances they compute from operations with the balance returned by the node.

This endpoint automatically returns all available sub-account types for the given account, including the main account balance and all sub-accounts (e.g., delegated, unbonding, rewards, etc.).

It is also possible to perform a historical balance lookup (if the server supports it) by passing in an optional BlockIdentifier.

This endpoint provides better performance and consistency compared to making multiple individual /account/balance requests, as all balances are guaranteed to be from the same block context.

post/account/all-balances

Request

  • The document declares no server URL.
  • Auth
    none declared

Request body

AllAccountBalancesRequest required

An AllAccountBalancesRequest is utilized to make a balance request for all sub-accounts on the /account/all-balances endpoint. This endpoint returns balances for the main account and all associated sub-accounts in a single request, eliminating the need to make multiple individual /account/balance calls for each sub-account.

The endpoint automatically returns all available sub-account types for the given account. If the block_identifier is populated, a historical balance query should be performed.

network_identifier, NetworkIdentifier required

The network_identifier specifies which network a particular object is associated with.

account_identifier, AccountIdentifier required

The account_identifier uniquely identifies an account within a network. All fields in the account_identifier are utilized to determine this uniqueness (including the metadata field, if populated).

block_identifier, PartialBlockIdentifier

When fetching data by BlockIdentifier, it may be possible to only specify the index or hash. If neither property is specified, it is assumed that the client is making a request at the current block.

currencies, Currency[]

In some cases, the caller may not want to retrieve all available balances for an AccountIdentifier. If the currencies field is populated, only balances for the specified currencies will be returned. If not populated, all available balances will be returned.

Example request

{
  "network_identifier": {
    "blockchain": "bitcoin",
    "network": "mainnet",
    "sub_network_identifier": {
      "network": "shard 1",
      "metadata": {
        "producer": "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5"
      }
    }
  },
  "account_identifier": {
    "address": "0x3a065000ab4183c6bf581dc1e55a605455fc6d61",
    "sub_account": {
      "address": "0x6b175474e89094c44da98b954eedeac495271d0f"
    }
  },
  "block_identifier": {
    "index": 1123941,
    "hash": "0x1f2cc6c5027d2f201a5453ad1119574d2aed23a392654742ac3c78783c071f85"
  },
  "currencies": [
    {
      "symbol": "BTC",
      "decimals": 8,
      "metadata": {
        "Issuer": "Satoshi"
      }
    }
  ]
}

Response

Expected response to a valid request

AllAccountBalancesResponse required

An AllAccountBalancesResponse is returned on the /account/all-balances endpoint. It contains balances for the main account and all associated sub-accounts, along with their respective sub-account identifiers and balance types.

This response provides all account balances in a single request, eliminating the need for multiple calls to /account/balance with different sub-account identifiers.

block_identifier, BlockIdentifier required

The block_identifier uniquely identifies a block in a particular network.

account_balances, AccountBalanceWithSubAccount[] required

Array of account balances including main account and all sub-accounts. Each balance includes balance type information and metadata.

Example response

{
  "block_identifier": {
    "index": 1123941,
    "hash": "0x1f2cc6c5027d2f201a5453ad1119574d2aed23a392654742ac3c78783c071f85"
  },
  "account_balances": [
    {
      "balances": [
        {
          "value": "1238089899992",
          "currency": {
            "symbol": "BTC",
            "decimals": 8,
            "metadata": {
              "Issuer": "Satoshi"
            }
          }
        }
      ],
      "balance_type": "spendable"
    }
  ]
}

Changes