Get Circulating Supply Of Moxie Token
In this tutorial, you will learn how to use the Circulating Supply API to fetch the circulating supply of the Moxie token in Node.js.
Pre-requisites
Before following the tutorial, make sure that your machine fulfills the following requirements:
- Node.js v.18+
- npm v.10+
In addition, make sure that you have node-fetch
installed in your Node.js project. If you haven't installed it yet, you can do so by running the following command:
- npm
- yarn
- pnpm
- bun
npm install node-fetch
yarn add node-fetch
pnpm add node-fetch
bun install node-fetch
Step 1: Add REST API Call To The Code
You can easily call the Circulating Supply API by sending a GET request using the following code snippet with node-fetch
:
- TypeScript
- JavaScript
import fetch from "node-fetch";
const options = {
method: "GET",
headers: {
accept: "application/json",
},
};
fetch("https://circulating-supply.moxie.xyz/", options)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));
const fetch = require("node-fetch");
const options = {
method: "GET",
headers: {
accept: "application/json",
},
};
fetch("https://circulating-supply.moxie.xyz/", options)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));
Step 2: Execute Your Code
Once you have your code ready, you can execute it by running the following command:
- TypeScript
- JavaScript
ts-node index.ts
node index.js
If it runs successfully, you should see the data returned in the terminal:
1004138103.91
Congrats! 🥳🎉 You've just fetched the circulating supply of the Moxie token!
Developer Support
If you have any questions or need help with other use cases, feel free to join the /airstack Warpcast channel and ask your questions there.
Our team is always ready to help you with any questions you may have.