Get account balance
const url = 'https://example.com/v1/accounts/0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1/balance/0x1%3A%3Aaptos_coin%3A%3AAptosCoin?ledger_version=32425224034';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://example.com/v1/accounts/0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1/balance/0x1%3A%3Aaptos_coin%3A%3AAptosCoin?ledger_version=32425224034'Retrieves account balance for coins / fungible asset (only for primary fungible asset store) for a given account, asset type and a specific ledger version. If the ledger version is not specified in the request, the latest ledger version is used.
The Aptos nodes prune account state history, via a configurable time window. If the requested ledger version has been pruned, the server responds with a 410.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”A hex encoded 32 byte Aptos account address.
This is represented in a string as a 64 character hex string, sometimes shortened by stripping leading 0s, and adding a 0x.
For example, address 0x0000000000000000000000000000000000000000000000000000000000000001 is represented as 0x1.
Example
0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1Address of account with or without a 0x prefix
A hex encoded 32 byte Aptos account address or a struct tag.
This is represented in a string as a 64 character hex string, sometimes
shortened by stripping leading 0s, and adding a 0x or
Format: {address}::{module name}::{struct name}
Example
0x1::aptos_coin::AptosCoinQuery Parameters
Section titled “ Query Parameters ”A string containing a 64-bit unsigned integer.
We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.
Example
32425224034Ledger version to get state of account
If not provided, it will be the latest version
Responses
Section titled “ Responses ”Example generated
1Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas
Cursor to be used for endpoints that support cursor-based
pagination. Pass this to the start field of the endpoint
on the next call to get the next page of results.
This is the generic struct we use for all API errors, it contains a string message and an Aptos API specific error code.
object
A message describing the error
These codes provide more granular error information beyond just the HTTP status code of the response.
A code providing VM error details when submitting transactions to the VM
Example
{ "error_code": "account_not_found"}Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas
This is the generic struct we use for all API errors, it contains a string message and an Aptos API specific error code.
object
A message describing the error
These codes provide more granular error information beyond just the HTTP status code of the response.
A code providing VM error details when submitting transactions to the VM
Example
{ "error_code": "account_not_found"}Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas
This is the generic struct we use for all API errors, it contains a string message and an Aptos API specific error code.
object
A message describing the error
These codes provide more granular error information beyond just the HTTP status code of the response.
A code providing VM error details when submitting transactions to the VM
Example
{ "error_code": "account_not_found"}Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas
This is the generic struct we use for all API errors, it contains a string message and an Aptos API specific error code.
object
A message describing the error
These codes provide more granular error information beyond just the HTTP status code of the response.
A code providing VM error details when submitting transactions to the VM
Example
{ "error_code": "account_not_found"}Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas
This is the generic struct we use for all API errors, it contains a string message and an Aptos API specific error code.
object
A message describing the error
These codes provide more granular error information beyond just the HTTP status code of the response.
A code providing VM error details when submitting transactions to the VM
Example
{ "error_code": "account_not_found"}Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas
This is the generic struct we use for all API errors, it contains a string message and an Aptos API specific error code.
object
A message describing the error
These codes provide more granular error information beyond just the HTTP status code of the response.
A code providing VM error details when submitting transactions to the VM
Example
{ "error_code": "account_not_found"}Headers
Section titled “ Headers ”Chain ID of the current chain
Current ledger version of the chain
Oldest non-pruned ledger version of the chain
Current timestamp of the chain
Current epoch of the chain
Current block height of the chain
Oldest non-pruned block height of the chain
The cost of the call in terms of gas