Overview

About blockchain APIs

A blockchain API is a set of programming interfaces that allow developers to access the functionality of a blockchain from within their own applications. It enables external programs to interact with the blockchain, read or write data to it, and execute smart contracts.

A blockchain API allows developers to build applications that can read or write data to the blockchain or that can execute smart contracts (which are self-executing contracts with the terms of the agreement between buyer and seller being directly written into lines of code).

πŸ“˜

A developer can use a blockchain API to build a decentralized exchange, a block explorer, or a supply chain management platform.

Blockchain APIs are an essential part of the blockchain ecosystem, enabling developers to build new applications and integrate them with existing ones. They allow different software to communicate with the blockchain and with each other.

About this reference

Node API

A collection of articles that explain how the most popular API methods work on the following networks:

Each method has a detailed explanation, real use case, and an interactive window to try it out.

Chainstack platform API

The Chainstack platform API allows you to manage:

  • Your organization
  • Your projects
  • Your networks
  • Your nodes
  • Your identities

To start with the API, you must create an API key.

For all available API operations, see API reference.

Getting started

Follow these steps to sign up on Chainstack, deploy a node, and find your endpoint credentials:

  1. Sign up with Chainstack.
  2. Deploy a node.
  3. View node access and credentials.

Make your first request

Chainstack's infrastructure allows you to access and retrieve data from a blockchain using JSON-RPC and the command line.

To make manual requests, it's recommended to use tools such as curl or Postman and send POST requests via JSON-RPC.

The following is an example of a curl request that interacts with a Chainstack node's JSON-RPC API.

curl -X POST "CHAINSTACK_NODE_URL" \
  -H 'Content-Type: application/json' \
  --data '{"method":"eth_blockNumber", "jsonrpc":"2.0", "params":[],"id":1}'

The request consists of the following:

  • curl -X POST which is used to initiate a POST request to the specified URL, a Chainstack node in this case; CHAINSTACK_NODE_URL.
  • -H 'Content-Type: application/json' specifies that the request's content type is in JSON format.
  • --data '{"method":"eth_blockNumber", "jsonrpc":"2.0", "params":[],"id":1}' is the request's payload, which contains the JSON-RPC request data.

The payload of the request contains the following fields:

  • method β€” defines the method that is being called, in this case, eth_blockNumber.
  • jsonrpc β€” defines the version of the JSON-RPC protocol in use; it is set to 2.0.
  • params β€” is used to pass any additional parameters required by the method; in this case, it is empty.
  • id β€” is used to identify the request. It is set to 1 in this case, and you can use id to identify the request the response belongs to.

This request is asking for the latest block number in the blockchain. The method eth_blockNumber will return the number of the most recent block in the chain.

Response example:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x24655cf"
}

Find different ways to interact and retrieve data from the blockchain in the Web3 libraries and tools guide.