Execute view function of a module
const url = 'https://example.com/v1/view?ledger_version=32425224034';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"function":"0x1::aptos_coin::transfer","type_arguments":["example"],"arguments":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url 'https://example.com/v1/view?ledger_version=32425224034' \ --header 'Content-Type: application/json' \ --data '{ "function": "0x1::aptos_coin::transfer", "type_arguments": [ "example" ], "arguments": [ "example" ] }'Execute the Move function with the given parameters and return its execution result.
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 ”Query 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
Request Body required
Section titled “ Request Body required ”View request for the Move View Function API
object
Entry function id is string representation of a entry function defined on-chain.
Format: {address}::{module name}::{function name}
Both module name and function name are case-sensitive.
Example
0x1::aptos_coin::transferType arguments of the function
Arguments of the function
Responses
Section titled “ Responses ”Move u8 value
Move u16 value
Move u32 value
Move u64 value
Move u128 value
Move u256 value
Move bool value
Move address value
Move vector value
Move bytes value
Move struct value
object
Move string value
Example
[ "32425224034"]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
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