API Reference

Each node in the Kaze-CLI provides an API interface for obtaining blockchain data from a node, making it easy to develop blockchain applications. The interface is provided via JSON-RPC, and the underlying protocol uses HTTP/HTTPS for communication. To start a node that provides an RPC service, run the following command:

dotnet kaze-cli.dll /rpc

To access the RPC server via HTTPS, you need to modify the configuration file config.json before starting the node and set the domain name, certificate, and password:

{
  "ApplicationConfiguration": {
    "Paths": {
      "Chain": "Chain"
    },
    "P2P": {
      "Port": 22886,
      "WsPort": 228857
    },
    "RPC": {
      "Port": 22885,
      "SslCert": "YourSslCertFile.xxx",
      "SslCertPassword": "YourPassword"
    }
  }
}                                      

After the JSON-RPC server starts, it will monitor the following ports, corresponding to the Main and Test nets:

For P2P and WebSocket information see Node/Introduction.

                                    / Main Net    /     Test Net
JSON-RPC HTTPS       22885               44885
JSON-RPC HTTP         22888               44888 

Command List

GET request example

A typical JSON-RPC GET request format is as follows:

The following is an example of how to get the number of blocks in the main chain.

Request URL:

http://somewebsite.com:10332?jsonrpc=2.0&method=getblockcount&params=[]&id=1

After sending the request, you will get the following response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": 909129
}

POST request example

The format of a typical JSON-RPC Post request is as follows:

The following is an example of how to get the number of blocks in the main chain.

Request URL:

http://somewebsite.com:10332

Request Body:

{
  "jsonrpc": "2.0",
  "method": "getblockcount",
  "params":[],
  "id": 1
}

After sending the request, you will get the following response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": 909122
}

Test tools

You can use the Chrome extension in Postman to facilitate the test (Installation of the Chrome extension requires Internet connection)

Did this answer your question?