Skip to content
Alchemy Logo

Sui API Quickstart

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.


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

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.

npmyarn
Begin with npm by following the npm documentation.For yarn, refer to yarn's installation guide.

To kickstart your project, open your terminal and execute the following commands:

mkdir sui-api-quickstart
cd sui-api-quickstart
npm init --yes

This creates a new directory named sui-api-quickstart and initializes a Node.js project within it.

Install Axios, a popular HTTP client, to make API requests:

npm install axios
# Or with yarn
# yarn add axios

Create an index.js file in your project directory and paste the following code:

const axios = require('axios');
 
const url = `https://sui-mainnet.alchemy-blast.com/v2/${yourAPIKey}`;
 
const payload = {
jsonrpc: '2.0',
id: 1,
method: 'sui_getLatestCheckpointSequenceNumber',
params: []
};
 
axios.post(url, payload)
.then(response => {
console.log('Latest checkpoint sequence number:', response.data.result);
})
.catch(error => {
console.error('Error fetching checkpoint:', error);
});
 

Remember to replace yourAPIKey with your actual Alchemy API key that you can get from your Alchemy dashboard.

To execute your script and make a request to the Sui App, run:

node index.js

You should see the latest checkpoint sequence number on Sui App outputted to your console:

Latest checkpoint sequence number: 1029433

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!

Was this page helpful?