Aptos API Quickstart
💡 Available only with Blast access
Introduction
Aptos is a next-generation Layer 1 blockchain designed for scalability, safety, and upgradeability. It leverages the Move programming language and a novel consensus mechanism to achieve high throughput and low latency.
With its modular architecture, Aptos supports frequent and instant upgrades, making it a dynamic platform for developers and users alike.
What is the Aptos Chain API?
The Aptos API provides developers with a set of tools to interact with the Aptos blockchain.
It offers both RESTful and JSON-RPC endpoints, allowing for seamless integration, transaction management, wallet interactions, and more.
Key features include:
- Account and Wallet Management: Create and manage Aptos accounts, check balances, and send/receive tokens.
- Transaction Handling: Initiate, sign, and broadcast transactions.
- Blockchain Data: Query blockchain data, such as account balances, block information, and transaction details.
- Smart Contract Execution: Interact with Aptos smart contracts to perform decentralized actions.
- Gas Estimates: Get current gas fees and estimate transaction costs.
- Event Streams: Subscribe to real-time blockchain events through WebSockets.
- Resource Access: Access blockchain resources like token metadata, account states, and more.
Getting Started Instructions
1. Choose a Package Manager (npm or yarn)
Your first step involves selecting a package manager, which will be crucial for managing your project’s dependencies. The choice between npm
and yarn
depends on your personal preference or project requirements.
2. Set Up Your Project
To kickstart your project, open your terminal and execute the following commands:
This creates a new directory named aptos-api-quickstart
and initializes a Node.js project within it.
3. Make Your First Request
Install Axios, a popular HTTP client, to make API requests:
Create an index.js
file in your project directory and paste the following code:
Remember to replace yourAPIKey
with your actual Alchemy API key that you can get from your Alchemy dashboard.
4. Run Your Script
To execute your script and make a request to the Aptos App, run:
You should see a list of Aptos accounts (if any exist on your node or fullnode) outputted to your console. For example:
Next Steps
Well done! You’ve just made your first request to the Aptos App API. With this foundation, you can dive deeper into the array of JSON-RPC methods available on Aptos App and start building your dApps on it!