Aptos (APT)
Aptos Network API Reference for seamless interaction with APT nodes, enabling fast, secure, and scalable transactions on a next-generation Layer 1 blockchain.
Overview of Aptos Network Methods
Aptos is a Layer 1 blockchain built with the Move programming language, designed to deliver a fast, secure, scalable, and upgradeable ecosystem. With its modular architecture, Aptos enables frequent upgrades, rapid adoption of new technologies, and strong support for emerging use cases. The Aptos API provides developers with the ability to interact with the blockchain seamlessly and possibly. You can do the following with the Aptos API:
Query real-time blockchain data
Manage and monitor accounts and balances
Interact with smart contracts
Submit and track transactions
Monitor network activity in real-time
Each method will provide you with the following:
Clear description of functionality and use cases
Required input parameters
Sample requests and responses
Supported network
Code example
Integration
Note: This API is compatible only with Aptos Mainnet.
Quickstart
In this section, you will learn how to make your first call with either:
Axios
Python
Quickstart with Axios
Before you begin, you must have already installed npm
or yarn
on your local machine. If not, check out npm or yarn.
Set up your project using this command:
For npm:
mkdir aptos-api-quickstart cd aptos-api-quickstart npm init --yes
Or yarn:
mkdir aptos-api-quickstart
cd aptos-api-quickstart
yarn init --yes
This creates a project directory named aptos-api-quickstart
and initialises a Node.js project within it.
Install Axios using this command: Using npm:
npm install axios
Using yarn:
yarn add axios
Create a new file and name it
index.js
. This is where you will make your first call.Set ES module
"type": "module"
in yourpackage.json
.Add the following code to the file (
index.js
):import axios from 'axios' let account = { method: 'get', url: 'https://go.getblock.io/<ACCESS_TOKEN>/v1/accounts/0xbf9239be9eb7e7a3d8e4c1f36083464fd47e6bd1f82a43b7c0f7ee958705a52f', }; axios.request(account) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });
Replace
<ACCESS_TOKEN>
with your actual access token from GetBlock.Run the script:
node index.js
The sequence number and authentication key log in your console like this:
{ "Sequence_number": "219241", "Authentication_key": "0xbf9239be9eb7e7a3d8e4c1f36083464fd47e6bd1f82a43b7c0f7ee958705a52f" }
Quickstart with Python and Requests
Before you begin, you must have installed Python and Pip on your local machine.
Set up your project using this command:
mkdir aptos-api-quickstart cd aptos-api-quickstart
Set up a virtual environment to isolate dependencies:
python -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
Install the requests library:
pip install requests
Create a new file called
main.py
and insert the following code:import requests url = "https://go.getblock.io/<ACCESS_TOKEN>/v1/accounts/0xbf9239be9eb7e7a3d8e4c1f36083464fd47e6bd1f82a43b7c0f7ee958705a52f" response = requests.get(url) print(response.text)
Replace
<ACCESS_TOKEN>
with your actual access token from GetBlock.Run the script:
python main.py
Endpoint Grouping
Blockchain Information
/v1
Account-Related
/v1/accounts/{account_hash}
/v1/accounts/{account_hash}/resources
/v1/accounts/{account_hash}/resource/{resource_type}
/v1/accounts/{account_hash}/modules
/v1/accounts/{account_hash}/module/{module_name}
/v1/accounts/{account_hash}/transactions
Events
/v1/accounts/{account_hash}/events/{creation_number}
/v1/accounts/{account_hash}/events/{event_handle}/{field_name}
Blocks
/v1/blocks/by_height/{block_height}
/v1/blocks/by_version/{version}
Transactions
/v1/transactions
/v1/transactions/by_hash/{transaction_hash}
/v1/transactions/by_version/{version}
Additional Utility
/v1/estimate_gas_price
Last updated