Sei API Quickstart
Get started building on Sei and using the JSON-RPC API
To use the Sei API you’ll need to create a free Alchemy account first!
Introduction
Sei is a high-performance blockchain designed for decentralized finance (DeFi) applications. It offers fast transaction speeds, scalability, and a developer-friendly environment, making it an ideal platform for deploying DeFi applications and services.
What is the Sei API?
The Sei API allows developers to interact with the Sei network through a collection of JSON-RPC methods. Given its compatibility with standard blockchain APIs, developers familiar with other blockchain JSON-RPC APIs will find working with Sei intuitive and straightforward.
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 sei-api-quickstart
and initializes a Node.js project within it.
3. Make Your First Request
For making API requests, we’ll use Axios, a widely-used HTTP client. Install Axios with the following command:
Next, create an index.js
file in your project directory. Paste the following code to send a request to the Sei network:
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 Sei network, run:
You should see the current block number on Sei (in hexadecimal format) outputted to your console:
Next Steps
Well done! You’ve just made your first request to the Sei API. With this foundation, you can dive deeper into the array of JSON-RPC methods available on Sei and start building your dApps on it!