Skip to main content

Fetch account balances

Intermediate
Tutorial

Overview

The account_balance endpoint allows you to fetch the balances for a certain account. It is the implementation of the /account/balance endpoint of the Rosetta API standard.

Prerequisites

  • Your Rosetta instance is up and running under the address 0.0.0.0:8082.

  • Make sure to use the correct NetworkIdentifier. For this example an arbitrary AccountIdentifier with the principal xmiu5-jqaaa-aaaag-qbz7q-cai and the default subaccount 0000000000000000000000000000000000000000000000000000000000000000 was used.

Example

curl --location '0.0.0.0:8082/account/balance'  --header 'Content-Type: application/json' --data '{
"network_identifier": {
"blockchain": "Internet Computer",
"network": "mxzaz-hqaaa-aaaar-qaada-cai"
},
"account_identifier": {
"address": "xmiu5-jqaaa-aaaag-qbz7q-cai",
"sub_account": {
"address": "0000000000000000000000000000000000000000000000000000000000000000"
}
}
}'

The response will give you the balance of the AccountIdentifier at the most recent block.

{
"block_identifier": {
"index": 1357692,
"hash": "5f1719c97f981f663f5ca612a24a503734eb87d5fbfc295193ab4a29ae139f3f"
},
"balances": [
{
"value": "134469737",
"currency": {
"symbol": "ckBTC",
"decimals": 8
}
}
]
}