Aptos Node API
v1.2.0https://apt.nownodes.io/v1The Aptos Node API is a RESTful API for client applications to interact with the Aptos blockchain.
Authentication
api-keyAuthapiKeyAPI Key: api-key in header
General
Accounts
Access to accounts, resources, and modules
Get token balance for an Aptos account
Returns the balance of a specific token (e.g. APT) for the given Aptos account address. The response is a raw number in micro-units (e.g. microAPT), which needs to be divided by 1,000,000 to get the APT value.
Parameters
addressstringrequiredpathThe Aptos account address in 0x-prefixed hexadecimal format.
token_typestringrequiredpathThe fully qualified token type. Use 0x1::aptos_coin::AptosCoin for native APT.
Response
Balance returned successfully (in microAPT)
Invalid address or token type
Account or token not found
Internal server error
Authorization
api-keyAuthapiKey in headerGet account
Return the authentication key and the sequence number for an account address. Optionally, a ledger version can be specified. If the ledger version is not specified in the request, the latest ledger version is used.
Parameters
addressAddress<hex>requiredpathAddress of account with or without a 0x prefix
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
Response
Authorization
api-keyAuthapiKey in headerGet account resources
Retrieves all account resources for a given account 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
addressAddress<hex>requiredpathAddress of account with or without a 0x prefix
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
startStateKeyWrapperqueryCursor specifying where to start for pagination
This cursor cannot be derived manually client-side. Instead, you must call this endpoint once without this query parameter specified, and then use the cursor returned in the X-Aptos-Cursor header in the response.
limitinteger<uint16>queryMax number of account resources to retrieve
If not provided, defaults to default page size.
Response
Authorization
api-keyAuthapiKey in headerGet account modules
Retrieves all account modules' bytecode for a given account at 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
addressAddress<hex>requiredpathAddress of account with or without a 0x prefix
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
startStateKeyWrapperqueryCursor specifying where to start for pagination
This cursor cannot be derived manually client-side. Instead, you must call this endpoint once without this query parameter specified, and then use the cursor returned in the X-Aptos-Cursor header in the response.
limitinteger<uint16>queryMax number of account modules to retrieve
If not provided, defaults to default page size.
Response
Authorization
api-keyAuthapiKey in headerGet account resource
Retrieves an individual resource from a given account and at 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
addressAddress<hex>requiredpathAddress of account with or without a 0x prefix
resource_typeMoveStructTagrequiredpathName of struct to retrieve e.g. 0x1::account::Account
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
Response
Authorization
api-keyAuthapiKey in headerGet account module
Retrieves an individual module from a given account and at 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
addressAddress<hex>requiredpathAddress of account with or without a 0x prefix
module_nameIdentifierWrapperrequiredpathName of module to retrieve e.g. coin
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
Response
Authorization
api-keyAuthapiKey in headerBlocks
Access to blocks
Get blocks by height
This endpoint allows you to get the transactions in a block and the corresponding block information.
Transactions are limited by max default transactions size. If not all transactions are present, the user will need to query for the rest of the transactions via the get transactions API.
If the block is pruned, it will return a 410
Parameters
block_heightinteger<uint64>requiredpathBlock height to lookup. Starts at 0
with_transactionsbooleanqueryIf set to true, include all transactions in the block
If not provided, no transactions will be retrieved
Response
Authorization
api-keyAuthapiKey in headerGet blocks by version
This endpoint allows you to get the transactions in a block and the corresponding block information given a version in the block.
Transactions are limited by max default transactions size. If not all transactions are present, the user will need to query for the rest of the transactions via the get transactions API.
If the block has been pruned, it will return a 410
Parameters
versioninteger<uint64>requiredpathLedger version to lookup block information for.
with_transactionsbooleanqueryIf set to true, include all transactions in the block
If not provided, no transactions will be retrieved
Response
Authorization
api-keyAuthapiKey in headerEvents
Access to events
Get events by creation number
Event types are globally identifiable by an account address and
monotonically increasing creation_number, one per event type emitted
to the given account. This API returns events corresponding to that
that event type.
Parameters
addressAddress<hex>requiredpathHex-encoded 32 byte Aptos account, with or without a 0x prefix, for
which events are queried. This refers to the account that events were
emitted to, not the account hosting the move module that emits that
event type.
creation_numberU64<uint64>requiredpathCreation number corresponding to the event stream originating from the given account.
startU64<uint64>queryStarting sequence number of events.
If unspecified, by default will retrieve the most recent events
limitinteger<uint16>queryMax number of events to retrieve.
If unspecified, defaults to default page size
Response
Authorization
api-keyAuthapiKey in headerGet events by event handle
This API uses the given account address, eventHandle, and fieldName
to build a key that can globally identify an event types. It then uses this
key to return events emitted to the given account matching that event type.
Parameters
addressAddress<hex>requiredpathHex-encoded 32 byte Aptos account, with or without a 0x prefix, for
which events are queried. This refers to the account that events were
emitted to, not the account hosting the move module that emits that
event type.
event_handleMoveStructTagrequiredpathName of struct to lookup event handle e.g. 0x1::account::Account
field_nameIdentifierWrapperrequiredpathName of field to lookup event handle e.g. withdraw_events
startU64<uint64>queryStarting sequence number of events.
If unspecified, by default will retrieve the most recent
limitinteger<uint16>queryMax number of events to retrieve.
If unspecified, defaults to default page size
Response
Authorization
api-keyAuthapiKey in headerGeneral
General information
Show OpenAPI explorer
Provides a UI that you can use to explore the API. You can also
retrieve the API directly at /spec.yaml and /spec.json.
Response
Authorization
api-keyAuthapiKey in headerCheck basic node health
By default this endpoint just checks that it can get the latest ledger info and then returns 200.
If the duration_secs param is provided, this endpoint will return a 200 if the following condition is true:
server_latest_ledger_info_timestamp >= server_current_time_timestamp - duration_secs
Parameters
duration_secsinteger<uint32>queryThreshold in seconds that the server can be behind to be considered healthy
If not provided, the healthcheck will always succeed
Response
Authorization
api-keyAuthapiKey in headerGet ledger info
Get the latest ledger information, including data such as chain ID, role type, ledger versions, epoch, etc.
Response
Authorization
api-keyAuthapiKey in headerTables
Access to tables
Get table item
Get a table item at a specific ledger version from the table identified by {table_handle} in the path and the "key" (TableItemRequest) provided in the request body.
This is a POST endpoint because the "key" for requesting a specific table item (TableItemRequest) could be quite complex, as each of its fields could themselves be composed of other structs. This makes it impractical to express using query params, meaning GET isn't an option.
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.
Body
Table Item request for the GetTableItem API
key_typeMoveTyperequiredString representation of an on-chain Move type tag that is exposed in transaction payload.
Values:
- bool
- u8
- u16
- u32
- u64
- u128
- u256
- address
- signer
- vector: vector<{non-reference MoveTypeId}>
- struct: {address}::{module_name}::{struct_name}::<{generic types}>
Vector type value examples:
- `vector<u8>`
- `vector<vector<u64>>`
- `vector<0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>>`
Struct type value examples:
- `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
- `0x1::account::Account`
Note:
1. Empty chars should be ignored when comparing 2 struct tag ids.
2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding).value_typeMoveTyperequiredString representation of an on-chain Move type tag that is exposed in transaction payload.
Values:
- bool
- u8
- u16
- u32
- u64
- u128
- u256
- address
- signer
- vector: vector<{non-reference MoveTypeId}>
- struct: {address}::{module_name}::{struct_name}::<{generic types}>
Vector type value examples:
- `vector<u8>`
- `vector<vector<u64>>`
- `vector<0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>>`
Struct type value examples:
- `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
- `0x1::account::Account`
Note:
1. Empty chars should be ignored when comparing 2 struct tag ids.
2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding).keyanyrequiredThe value of the table item's key
Parameters
table_handleAddress<hex>requiredpathTable handle hex encoded 32-byte string
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
Response
Authorization
api-keyAuthapiKey in headerGet raw table item
Get a table item at a specific ledger version from the table identified by {table_handle} in the path and the "key" (RawTableItemRequest) provided in the request body.
The get_raw_table_item requires only a serialized key comparing to the full move type information
comparing to the get_table_item api, and can only return the query in the bcs format.
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.
Body
Table Item request for the GetTableItemRaw API
keyHexEncodedBytes<hex>requiredAll bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with
two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Parameters
table_handleAddress<hex>requiredpathTable handle hex encoded 32-byte string
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
Response
Authorization
api-keyAuthapiKey in headerTransactions
Access to transactions
Get transactions
Retrieve on-chain committed transactions. The page size and start ledger version can be provided to get a specific sequence of transactions.
If the version has been pruned, then a 410 will be returned.
To retrieve a pending transaction, use /transactions/by_hash.
Parameters
startU64<uint64>queryLedger version to start list of transactions
If not provided, defaults to showing the latest transactions
limitinteger<uint16>queryMax number of transactions to retrieve.
If not provided, defaults to default page size
Response
Authorization
api-keyAuthapiKey in headerSubmit transaction
This endpoint accepts transaction submissions in two formats.
To submit a transaction as JSON, you must submit a SubmitTransactionRequest. To build this request, do the following:
- Encode the transaction as BCS. If you are using a language that has native BCS support, make sure of that library. If not, you may take advantage of /transactions/encode_submission. When using this endpoint, make sure you trust the node you're talking to, as it is possible they could manipulate your request.
- Sign the encoded transaction and use it to create a TransactionSignature.
- Submit the request. Make sure to use the "application/json" Content-Type.
To submit a transaction as BCS, you must submit a SignedTransaction
encoded as BCS. See SignedTransaction in types/src/transaction/mod.rs.
Make sure to use the application/x.aptos.signed_transaction+bcs Content-Type.
Body
application/jsonSubmitTransactionRequestA request to submit a transaction
This requires a transaction and a signature of it
senderAddress<hex>requiredA 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.
sequence_numberU64<uint64>requiredA 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.
max_gas_amountU64<uint64>requiredA 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.
gas_unit_priceU64<uint64>requiredA 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.
expiration_timestamp_secsU64<uint64>requiredA 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.
payloadobject & EntryFunctionPayload | object & ScriptPayload | object & ModuleBundlePayload | object & MultisigPayloadrequiredAn enum of the possible transaction payloads
signatureobject & Ed25519Signature | object & MultiEd25519Signature | object & MultiAgentSignature | object & FeePayerSignature | object & object & Ed25519Signature | object & MultiEd25519Signature | object & SingleKeySignature | object & MultiKeySignaturerequiredAn enum representing the different transaction signatures available
application/x.aptos.signed_transaction+bcsArray<integer>Response
Authorization
api-keyAuthapiKey in headerGet transaction by hash
Look up a transaction by its hash. This is the same hash that is returned by the API when submitting a transaction (see PendingTransaction).
When given a transaction hash, the server first looks for the transaction in storage (on-chain, committed). If no on-chain transaction is found, it looks the transaction up by hash in the mempool (pending, not yet committed).
To create a transaction hash by yourself, do the following:
- Hash message bytes: "RawTransaction" bytes + BCS bytes of Transaction.
- Apply hash algorithm
SHA3-256to the hash message bytes. - Hex-encode the hash bytes with
0xprefix.
Parameters
txn_hashHashValuerequiredpathHash of transaction to retrieve
Response
Authorization
api-keyAuthapiKey in headerGet transaction by version
Retrieves a transaction by a given version. If the version has been pruned, a 410 will be returned.
Parameters
txn_versionU64<uint64>requiredpathVersion of transaction to retrieve
Response
Authorization
api-keyAuthapiKey in headerGet account transactions
Retrieves on-chain committed transactions from an account. If the start version is too far in the past, a 410 will be returned.
If no start version is given, it will start at version 0.
To retrieve a pending transaction, use /transactions/by_hash.
Parameters
addressAddress<hex>requiredpathAddress of account with or without a 0x prefix
startU64<uint64>queryAccount sequence number to start list of transactions
If not provided, defaults to showing the latest transactions
limitinteger<uint16>queryMax number of transactions to retrieve.
If not provided, defaults to default page size
Response
Authorization
api-keyAuthapiKey in headerSubmit batch transactions
This allows you to submit multiple transactions. The response has three outcomes:
- All transactions succeed, and it will return a 202
- Some transactions succeed, and it will return the failed transactions and a 206
- No transactions succeed, and it will also return the failed transactions and a 206
To submit a transaction as JSON, you must submit a SubmitTransactionRequest. To build this request, do the following:
- Encode the transaction as BCS. If you are using a language that has native BCS support, make sure to use that library. If not, you may take advantage of /transactions/encode_submission. When using this endpoint, make sure you trust the node you're talking to, as it is possible they could manipulate your request.
- Sign the encoded transaction and use it to create a TransactionSignature.
- Submit the request. Make sure to use the "application/json" Content-Type.
To submit a transaction as BCS, you must submit a SignedTransaction
encoded as BCS. See SignedTransaction in types/src/transaction/mod.rs.
Make sure to use the application/x.aptos.signed_transaction+bcs Content-Type.
Body
application/jsonArray<SubmitTransactionRequest>application/x.aptos.signed_transaction+bcsArray<integer>Response
Authorization
api-keyAuthapiKey in headerSimulate transaction
The output of the transaction will have the exact transaction outputs and events that running an actual signed transaction would have. However, it will not have the associated state hashes, as they are not updated in storage. This can be used to estimate the maximum gas units for a submitted transaction.
To use this, you must:
- Create a SignedTransaction with a zero-padded signature.
- Submit a SubmitTransactionRequest containing a UserTransactionRequest containing that signature.
To use this endpoint with BCS, you must submit a SignedTransaction encoded as BCS. See SignedTransaction in types/src/transaction/mod.rs.
Body
application/jsonSubmitTransactionRequestA request to submit a transaction
This requires a transaction and a signature of it
senderAddress<hex>requiredA 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.
sequence_numberU64<uint64>requiredA 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.
max_gas_amountU64<uint64>requiredA 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.
gas_unit_priceU64<uint64>requiredA 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.
expiration_timestamp_secsU64<uint64>requiredA 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.
payloadobject & EntryFunctionPayload | object & ScriptPayload | object & ModuleBundlePayload | object & MultisigPayloadrequiredAn enum of the possible transaction payloads
signatureobject & Ed25519Signature | object & MultiEd25519Signature | object & MultiAgentSignature | object & FeePayerSignature | object & object & Ed25519Signature | object & MultiEd25519Signature | object & SingleKeySignature | object & MultiKeySignaturerequiredAn enum representing the different transaction signatures available
application/x.aptos.signed_transaction+bcsArray<integer>Parameters
estimate_max_gas_amountbooleanqueryIf set to true, the max gas value in the transaction will be ignored and the maximum possible gas will be used
estimate_gas_unit_pricebooleanqueryIf set to true, the gas unit price in the transaction will be ignored and the estimated value will be used
estimate_prioritized_gas_unit_pricebooleanqueryIf set to true, the transaction will use a higher price than the original estimate.
Response
Authorization
api-keyAuthapiKey in headerEncode submission
This endpoint accepts an EncodeSubmissionRequest, which internally is a UserTransactionRequestInner (and optionally secondary signers) encoded as JSON, validates the request format, and then returns that request encoded in BCS. The client can then use this to create a transaction signature to be used in a SubmitTransactionRequest, which it then passes to the /transactions POST endpoint.
To be clear, this endpoint makes it possible to submit transaction requests to the API from languages that do not have library support for BCS. If you are using an SDK that has BCS support, such as the official Rust, TypeScript, or Python SDKs, you do not need to use this endpoint.
To sign a message using the response from this endpoint:
- Decode the hex encoded string in the response to bytes.
- Sign the bytes to create the signature.
- Use that as the signature field in something like Ed25519Signature, which you then use to build a TransactionSignature.
Body
Request to encode a submission
senderAddress<hex>requiredA 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.
sequence_numberU64<uint64>requiredA 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.
max_gas_amountU64<uint64>requiredA 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.
gas_unit_priceU64<uint64>requiredA 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.
expiration_timestamp_secsU64<uint64>requiredA 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.
payloadobject & EntryFunctionPayload | object & ScriptPayload | object & ModuleBundlePayload | object & MultisigPayloadrequiredAn enum of the possible transaction payloads
secondary_signersArray<Address>Secondary signer accounts of the request for Multi-agent
Response
Authorization
api-keyAuthapiKey in headerEstimate gas price
Gives an estimate of the gas unit price required to get a transaction on chain in a reasonable amount of time. The gas unit price is the amount that each transaction commits to pay for each unit of gas consumed in executing the transaction. The estimate is based on recent history: it gives the minimum gas that would have been required to get into recent blocks, for blocks that were full. (When blocks are not full, the estimate will match the minimum gas unit price.)
The estimation is given in three values: de-prioritized (low), regular, and prioritized (aggressive). Using a more aggressive value increases the likelihood that the transaction will make it into the next block; more aggressive values are computed with a larger history and higher percentile statistics. More details are in AIP-34.
Response
Authorization
api-keyAuthapiKey in headerView
View functions,
Execute view function of a module
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.
Body
application/jsonViewRequestView request for the Move View Function API
functionEntryFunctionIdrequiredEntry 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.
type_argumentsArray<MoveType>requiredType arguments of the function
argumentsArray<any>requiredArguments of the function
application/x.aptos.view_function+bcsArray<integer>Parameters
ledger_versionU64<uint64>queryLedger version to get state of account
If not provided, it will be the latest version
Response
Authorization
api-keyAuthapiKey in header