Select target C C# Clojure Dart F# Go HTTP Java JavaScript Julia Kotlin Node.js Objective-C OCaml PHP PowerShell Python R Ruby Rust Shell Swift Select client Curl Wget HTTPie Test request curl_global_init(CURL_GLOBAL_DEFAULT) ;
CURL * curl = curl_easy_init() ;
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, " GET " ) ;
curl_easy_setopt(curl, CURLOPT_URL, " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " ) ;
CURLcode res = curl_easy_perform(curl) ;
using var client = new HttpClient();
var request = new HttpRequestMessage( HttpMethod . Get , " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " );
using var response = await client . SendAsync (request);
var client = new RestClient( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " );
var request = new RestRequest( "" , Method . Get );
var response = await client . ExecuteAsync (request);
( require '[clj-http.client :as client])
( client/get " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
import 'package:http/http.dart' as http;
final response = await http. get ( Uri . parse ( 'https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type}' ));
let httpRequestMessage = new HttpRequestMessage (
new Uri ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
let client = new HttpClient ()
let! result = client.SendAsync ( httpRequestMessage )
requestUrl := " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} "
req , _ := http . NewRequest ( " GET " , requestUrl , nil )
res , _ := http . DefaultClient . Do ( req )
body , _ := io . ReadAll ( res . Body )
fmt . Println ( string ( body ))
GET /v1/accounts/{address}/balance/{asset_type} HTTP / 1.1
Host : api.mainnet.aptoslabs.com
try ( AsyncHttpClient client = new DefaultAsyncHttpClient () ) {
Response response = client . prepare ( " GET " , " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
System . out . println ( response . getResponseBody ()) ;
HttpClient client = HttpClient . newHttpClient () ;
HttpRequest request = HttpRequest . newBuilder ()
. uri ( java . net . URI . create ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " ))
. method ( " GET " , HttpRequest . BodyPublishers . noBody ())
HttpResponse < String > response = client . send ( request, HttpResponse . BodyHandlers . ofString ()) ;
System . out . println ( response . body ()) ;
OkHttpClient client = new OkHttpClient () ;
Request request = new Request. Builder ()
. url ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
try ( Response response = client . newCall ( request ) . execute () ) {
System . out . println ( response . body () . string ()) ;
HttpResponse < String > response = Unirest . request ( " GET " , " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
System . out . println ( response . getBody ()) ;
fetch ( ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' )
import axios from ' axios '
url: ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} '
const { data } = await axios . request ( options )
import { ofetch } from ' ofetch '
ofetch ( ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' )
url: " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " ,
}) . done ( ( response ) => console . log ( response ));
const xhr = new XMLHttpRequest ();
xhr . open ( " GET " , " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " );
xhr . withCredentials = true ;
xhr . addEventListener ( " load " , () => console . log ( xhr . responseText ));
response = HTTP . get ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
println ( String (response . body))
val client = OkHttpClient ()
val request = Request. Builder ()
. url ( "https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type}" )
val response = client. newCall (request). execute ()
fetch ( ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' )
import axios from ' axios '
url: ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} '
const { data } = await axios . request ( options )
import { ofetch } from ' ofetch '
ofetch ( ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' )
import { request } from ' undici '
const { statusCode , body } = await request ( ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' )
#import < Foundation/Foundation.h >
NSMutableURLRequest * request = [ NSMutableURLRequest requestWithURL : [ NSURL URLWithString : @" https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " ]
cachePolicy : NSURLRequestUseProtocolCachePolicy
[request setHTTPMethod : @" GET " ];
NSURLSession * session = [NSURLSession sharedSession ];
NSURLSessionDataTask * dataTask = [session dataTaskWithRequest : request
completionHandler : ^ ( NSData * data, NSURLResponse * response, NSError * error) {
NSHTTPURLResponse * httpResponse = ( NSHTTPURLResponse * ) response;
NSLog ( @" %@ " , httpResponse);
let uri = Uri . of_string "https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type}" in
let headers = Cohttp . Header . of_list [
Cohttp_lwt_unix . Client . call ~ headers ( Cohttp . Code . method_of_string "GET" ) uri
>>= fun ( _response , body ) ->
Cohttp_lwt . Body . to_string body >>= Lwt_io . printl
$ch = curl_init ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " );
$client = new GuzzleHttp\ Client ();
$response = $client -> request ( ' GET ' , ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' );
use Illuminate\Support\Facades\ Http ;
$response = Http :: get ( ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' );
$response = Invoke-WebRequest - Uri ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' - Method ' GET '
$response = Invoke-RestMethod - Uri ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} ' - Method ' GET '
conn = http.client. HTTPSConnection ( " api.mainnet.aptoslabs.com " )
conn. request ( " GET " , " /v1/accounts/ {address} /balance/ {asset_type} " )
response = conn. getresponse ()
print ( response. read () . decode ())
" https://api.mainnet.aptoslabs.com/v1/accounts/ {address} /balance/ {asset_type} "
async with aiohttp. ClientSession () as session:
" https://api.mainnet.aptoslabs.com/v1/accounts/ {address} /balance/ {asset_type} "
" https://api.mainnet.aptoslabs.com/v1/accounts/ {address} /balance/ {asset_type} "
async with httpx. AsyncClient () as client:
" https://api.mainnet.aptoslabs.com/v1/accounts/ {address} /balance/ {asset_type} "
response <- request ( "https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type}" ) |>
resp_body_string ( response )
url = URI ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " )
http = Net :: HTTP . new (url. host , url. port )
request = Net :: HTTP :: Get . new (url)
response = http. request (request)
let client = reqwest :: Client :: new ();
let request = client . get ( " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " );
let response = request . send () . await ? ;
curl ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} '
- ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} '
http --ignore-stdin ' GET ' ' https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} '
var request = URLRequest ( url : URL ( string : " https://api.mainnet.aptoslabs.com/v1/accounts/{address}/balance/{asset_type} " ) ! )
request. httpMethod = " GET "
let ( data, response ) = try await URLSession. shared . data ( for : request )
guard let httpResponse = response as? HTTPURLResponse,
200 ..< 300 ~= httpResponse.statusCode else {
throw URLError ( . badServerResponse )
print ( String ( data : data, encoding : .utf8 ) ?? "" )
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.
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.
string format: hex
Example
0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
Address 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}
string format: hex
Example
0x1::aptos_coin::AptosCoin
ledger_version
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.
string format: uint64
Ledger version to get state of account
If not provided, it will be the latest version
Select media type application/json application/x-bcs X-APTOS-CHAIN-ID required
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION required
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION required
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC required
integer format: uint64
Current timestamp of the chain
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT required
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT required
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
X-APTOS-CURSOR
string
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.
Media type application/json
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
string
These codes provide more granular error information beyond just the HTTP
status code of the response.
string
Allowed values: account_not_found resource_not_found module_not_found struct_field_not_found version_not_found transaction_not_found table_item_not_found block_not_found state_value_not_found version_pruned block_pruned invalid_input invalid_transaction_update sequence_number_too_old vm_error rejected_by_filter health_check_failed mempool_is_full internal_error web_framework_error bcs_not_supported api_disabled
vm_error_code
A code providing VM error details when submitting transactions to the VM
integer format: uint64
Example
"error_code" : " account_not_found "
X-APTOS-CHAIN-ID
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
Media type application/json
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
string
These codes provide more granular error information beyond just the HTTP
status code of the response.
string
Allowed values: account_not_found resource_not_found module_not_found struct_field_not_found version_not_found transaction_not_found table_item_not_found block_not_found state_value_not_found version_pruned block_pruned invalid_input invalid_transaction_update sequence_number_too_old vm_error rejected_by_filter health_check_failed mempool_is_full internal_error web_framework_error bcs_not_supported api_disabled
vm_error_code
A code providing VM error details when submitting transactions to the VM
integer format: uint64
Example
"error_code" : " account_not_found "
X-APTOS-CHAIN-ID
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
Media type application/json
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
string
These codes provide more granular error information beyond just the HTTP
status code of the response.
string
Allowed values: account_not_found resource_not_found module_not_found struct_field_not_found version_not_found transaction_not_found table_item_not_found block_not_found state_value_not_found version_pruned block_pruned invalid_input invalid_transaction_update sequence_number_too_old vm_error rejected_by_filter health_check_failed mempool_is_full internal_error web_framework_error bcs_not_supported api_disabled
vm_error_code
A code providing VM error details when submitting transactions to the VM
integer format: uint64
Example
"error_code" : " account_not_found "
X-APTOS-CHAIN-ID
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
Media type application/json
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
string
These codes provide more granular error information beyond just the HTTP
status code of the response.
string
Allowed values: account_not_found resource_not_found module_not_found struct_field_not_found version_not_found transaction_not_found table_item_not_found block_not_found state_value_not_found version_pruned block_pruned invalid_input invalid_transaction_update sequence_number_too_old vm_error rejected_by_filter health_check_failed mempool_is_full internal_error web_framework_error bcs_not_supported api_disabled
vm_error_code
A code providing VM error details when submitting transactions to the VM
integer format: uint64
Example
"error_code" : " account_not_found "
X-APTOS-CHAIN-ID
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
Media type application/json
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
string
These codes provide more granular error information beyond just the HTTP
status code of the response.
string
Allowed values: account_not_found resource_not_found module_not_found struct_field_not_found version_not_found transaction_not_found table_item_not_found block_not_found state_value_not_found version_pruned block_pruned invalid_input invalid_transaction_update sequence_number_too_old vm_error rejected_by_filter health_check_failed mempool_is_full internal_error web_framework_error bcs_not_supported api_disabled
vm_error_code
A code providing VM error details when submitting transactions to the VM
integer format: uint64
Example
"error_code" : " account_not_found "
X-APTOS-CHAIN-ID
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas
Media type application/json
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
string
These codes provide more granular error information beyond just the HTTP
status code of the response.
string
Allowed values: account_not_found resource_not_found module_not_found struct_field_not_found version_not_found transaction_not_found table_item_not_found block_not_found state_value_not_found version_pruned block_pruned invalid_input invalid_transaction_update sequence_number_too_old vm_error rejected_by_filter health_check_failed mempool_is_full internal_error web_framework_error bcs_not_supported api_disabled
vm_error_code
A code providing VM error details when submitting transactions to the VM
integer format: uint64
Example
"error_code" : " account_not_found "
X-APTOS-CHAIN-ID
integer format: uint8
Chain ID of the current chain
X-APTOS-LEDGER-VERSION
integer format: uint64
Current ledger version of the chain
X-APTOS-LEDGER-OLDEST-VERSION
integer format: uint64
Oldest non-pruned ledger version of the chain
X-APTOS-LEDGER-TIMESTAMPUSEC
integer format: uint64
Current timestamp of the chain
X-APTOS-EPOCH
integer format: uint64
Current epoch of the chain
X-APTOS-BLOCK-HEIGHT
integer format: uint64
Current block height of the chain
X-APTOS-OLDEST-BLOCK-HEIGHT
integer format: uint64
Oldest non-pruned block height of the chain
X-APTOS-GAS-USED
integer format: uint64
The cost of the call in terms of gas