This page will help you get started with Node Service.
Overview
ZAN Node Service provides reliable and robust blockchain infrastructure solutions with enterprise-grade performance and security. This guide helps you get started with our API services quickly.
ZAN Node Service provides a set of JSON-RPC APIs for you to interact with the blockchain, which are similar to the JSON-RPC APIs provided by the native node client. The easiest way to use the APIs is directly sending an HTTP POST request with the API key in the URL. Here's an example to use curl to send an HTTP POST request to get the latest block number of Ethereum mainnet.
## JSON-RPC over HTTP POST
## Replace {apiKey} with the API key you obtained from the ZAN dashboard.
## You can also replace the "eth" and "mainnet" with any other supported networks.
curl https://api.zan.top/node/v1/eth/mainnet/{apiKey} \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
And here's an example to use wscat to send a WebSocket request for the same purpose.
## JSON-RPC over WSS
## Replace {apiKey} with the API key you obtained from the ZAN dashboard.
## You can also replace the "eth" and "mainnet" with any other supported networks.
wscat -c wss://api.zan.top/node/ws/v1/eth/mainnet/{apiKey}
>{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}
See Supported Ecosystems for the endpoint URLs of the currently supported ecosystems.
See the API reference of each ecosystem for more information about the available APIs.
Authentication Methods
API Key Authentication
All API requests must be authenticated using your API key. Follow the instructions on Quickstart Guide to obtain your API key from the ZAN Node Service Console .
If you plan to use the APIs in a programming language, there are plenty of libraries to help with that, including:
web3.js (for JavaScript)
var Web3 = require('web3');
var provider = 'https://api.zan.top/node/v1/eth/mainnet/{apiKey}';
var web3Provider = new Web3.providers.HttpProvider(provider);
var web3 = new Web3(web3Provider);
web3.eth.getBlockNumber().then((result) => {
console.log("getBlockNumber(): ",result);
});