For AI agents: an LLM-friendly Markdown version of every page is available by appending .md to its URL or by sending an Accept: text/markdown request header. The full documentation index is at https://www.ankr.com/docs/llms.txt
Skip to main content

Aptos — Accounts, Blocks, Events, General, Table, Transactions (1/2)

API reference for Aptos. All methods ->

Part 1 of 2: 1 · 2

Accounts

Get account

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}

Returns 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

  • address (string; hex; path; required): an address of account with or without a 0x prefix.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address} \
-H 'Content-Type: application/json'

Response example

{
"sequence_number": "32425224034",
"authentication_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}

Get account resources

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/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

  • address (string; hex; path; required): an address of account with or without a 0x prefix.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034
  • limit (integer; query): max number of account resources to retrieve. If not provided, retrieves a default page size.
  • start (string; query): cursor 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.
    Example: 0000000000000000000000000000000000000000000000000000000000000000012f0000000000000000000000000000000000000000000000000000000000000000010d7374616b696e675f70726f7879

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/resources \
-H 'Content-Type: application/json'

Response example

[
{
"type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
"data": {
"authentication_key": "0x0000000000000000000000000000000000000000000000000000000000000001",
"coin_register_events": {
"counter": "0",
"guid": {
"id": {
"addr": "0x1",
"creation_num": "0"
}
}
},
"self_address": "0x1",
"sequence_number": "0"
}
}
]

Get account modules

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/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

  • address (string; hex; path; required): an address of account with or without a 0x prefix.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034
  • limit (integer; query): max number of account resources to retrieve. If not provided, retrieves a default page size.
  • start (string; query): cursor 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.
    Example: 0000000000000000000000000000000000000000000000000000000000000000012f0000000000000000000000000000000000000000000000000000000000000000010d7374616b696e675f70726f7879

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/modules \
-H 'Content-Type: application/json'

Response example

[
{
"bytecode": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"abi": {
"address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"name": "string",
"friends": [
"0x1::aptos_coin"
],
"exposed_functions": [
{
"name": "string",
"visibility": "private",
"is_entry": true,
"generic_type_params": [
{
"constraints": [
"string"
]
}
],
"params": [
"string"
],
"return": [
"string"
]
}
],
"structs": [
{
"name": "string",
"is_native": true,
"abilities": [
"string"
],
"generic_type_params": [
{
"constraints": [
"string"
]
}
],
"fields": [
{
"name": "string",
"type": "string"
}
]
}
]
}
}
]

Get account resource

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/resource/{resource_type}

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

  • address (string; hex; path; required): an address of account with or without a 0x prefix.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • resource_type (string; path; required) a name of struct to retrieve.
    Example: 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
    Match pattern: ^0x[0-9a-zA-Z:_<>]+$
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/resource/{resource_type} \
-H 'Content-Type: application/json'

Response example

{
"type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
"data": {
"authentication_key": "0x0000000000000000000000000000000000000000000000000000000000000001",
"coin_register_events": {
"counter": "0",
"guid": {
"id": {
"addr": "0x1",
"creation_num": "0"
}
}
},
"self_address": "0x1",
"sequence_number": "0"
}
}

Get account module

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/module/{module_name}

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

  • address (string; hex; path; required): an address of account with or without a 0x prefix.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • module_name (string; path; required): a name of module to retrieve (example: coin).
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/module/{module_name} \
-H 'Content-Type: application/json'

Response example

{
"bytecode": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"abi": {
"address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"name": "string",
"friends": [
"0x1::aptos_coin"
],
"exposed_functions": [
{
"name": "string",
"visibility": "private",
"is_entry": true,
"generic_type_params": [
{
"constraints": [
"string"
]
}
],
"params": [
"string"
],
"return": [
"string"
]
}
],
"structs": [
{
"name": "string",
"is_native": true,
"abilities": [
"string"
],
"generic_type_params": [
{
"constraints": [
"string"
]
}
],
"fields": [
{
"name": "string",
"type": "string"
}
]
}
]
}
}

Blocks

Get blocks by height

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/blocks/by_height/{block_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_height (integer; path; required): a block height to look up. Starts at 0.
  • with_transactions (boolean; query): if set to true, includes all transactions in the block. If not provided, no transactions will be retrieved.

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/blocks/by_height/{block_height} \
-H 'Content-Type: application/json'

Response example

{
"block_height": "32425224034",
"block_hash": "string",
"block_timestamp": "32425224034",
"first_version": "32425224034",
"last_version": "32425224034",
"transactions": [
{
"type": "pending_transaction",
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
]
}

Get blocks by version

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/blocks/by_version/{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

  • version (integer; path; required): a ledger version to look up block information for.
  • with_transactions (boolean; query): if set to true, includes all transactions in the block. If not provided, no transactions will be retrieved.

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/blocks/by_version/{version} \
-H 'Content-Type: application/json'

Response example

{
"block_height": "32425224034",
"block_hash": "string",
"block_timestamp": "32425224034",
"first_version": "32425224034",
"last_version": "32425224034",
"transactions": [
{
"type": "pending_transaction",
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
]
}

Events

Get events by creation number

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/events/{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

  • address (string; hex; path; required): a hex-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.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • creation_number (string; uint64; path; required): a creation number corresponding to the event stream originating from the given account.
  • limit (integer; query): max number of events to retrieve. If unspecified, defaults to default page size.
  • start (string; uint64; query): the starting sequence number of events. If unspecified, by default will retrieve the most recent events.
    Example: 32425224034

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/events/{creation_number} \
-H 'Content-Type: application/json'

Response example

[
{
"version": "32425224034",
"guid": {
"creation_number": "32425224034",
"account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
},
"sequence_number": "32425224034",
"type": "string",
"data": null
}
]

Get events by event handle

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/events/{event_handle}/{field_name}

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

  • address (string; hex; path; required): a hex-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.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • event_handle (string; path; required): a name of struct to look up event handle.
    Example: 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
    Match pattern: ^0x[0-9a-zA-Z:_<>]+$
  • field_name (string; path; required): a name of field to look up event handle (example: withdraw_events).
  • limit (integer; query): max number of events to retrieve. If unspecified, defaults to default page size.
  • start (string; uint64; query): the starting sequence number of events. If unspecified, by default will retrieve the most recent events.
    Example: 32425224034

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/events/{event_handle}/{field_name} \
-H 'Content-Type: application/json'

Response example

[
{
"version": "32425224034",
"guid": {
"creation_number": "32425224034",
"account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
},
"sequence_number": "32425224034",
"type": "string",
"data": null
}
]

General

Get ledger info

GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/

Retrieves the latest ledger information, including data such as chain ID, role type, ledger versions, epoch, etc.

Parameters

None.

Request example

curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/ \
-H 'Content-Type: application/json'

Response example

{
"chain_id": 0,
"epoch": "32425224034",
"ledger_version": "32425224034",
"oldest_ledger_version": "32425224034",
"ledger_timestamp": "32425224034",
"node_role": "validator",
"oldest_block_height": "32425224034",
"block_height": "32425224034",
"git_hash": "string"
}

Table

Get table item

POST https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/tables/{table_handle}/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.

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

  • table_handle (string; hex; path; required): a table handle hex encoded 32-byte string.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034
  • key_type (string; body; required): a string 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).
    Match patterns: ^(bool|u8|u64|u128|address|signer|vector<.+>|0x[0-9a-zA-Z:_<, >]+)$
  • value_type (string; body; required): a string 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).
    Match pattern: ^(bool|u8|u64|u128|address|signer|vector<.+>|0x[0-9a-zA-Z:_<, >]+)$
  • key (body; required): the value of the table item's key.

Request example

curl -X POST https://rpc.ankr.com/premium/YOUR_ANKR_API_KEY-http/aptos/YOUR_ANKR_API_KEY/v1/tables/{table_handle}/item \
-H 'Content-Type: application/json' \
-d '{
"key_type": "string",
"value_type": "string",
"key": null
}'

Response example

0

Get raw table item

POST https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/tables/{table_handle}/raw_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.

Parameters

  • table_handle (string; hex; path; required): a table handle hex encoded 32-byte string.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
  • ledger_version (string; uint64; query): a ledger version to get state of account. If not provided, it will be the latest version.
    Example: 32425224034
  • key (string; hex; body; required): all 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.
    Example: 0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1

Request example

curl -X POST https://rpc.ankr.com/premium/YOUR_ANKR_API_KEY-http/aptos/YOUR_ANKR_API_KEY/v1/tables/{table_handle}/item \
-H 'Content-Type: application/json' \
-d '{
"key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}'

Response example

0