Sui API Quickstart
💡 Available only with Blast access
Introduction
The Sui API enables developers to interact with the Sui blockchain via a collection of JSON-RPC endpoints. With this API, you can query block and transaction data, interact with Move-based smart contracts, manage assets, and more.
Unlike Ethereum-based chains, Sui uses an object-centric data model, optimized for parallel execution and scalability. This quickstart will help you make your first request to the network.
What is the Sui Chain API?
The Sui Chain API allows developers to send queries and transactions to the Sui blockchain through a JSON-RPC interface. With Sui’s object-based architecture and horizontal scalability, developers benefit from high throughput and low-latency reads and writes.
Alchemy’s Sui API provides developers with consistent and performant access to:
- Retrieving account and object data
- Querying blocks, transactions, and events
- Simulating and broadcasting transactions
- Accessing Move smart contract modules and functions
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 sui-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 Sui App, run:
You should see the latest checkpoint sequence number on Sui App outputted to your console:
Next Steps
Well done! You’ve just made your first request to the Sui App API. With this foundation, you can dive deeper into the array of JSON-RPC methods available on Sui App and start building your dApps on it!