Kava REST Server Guide

Kevin Davis
2 min readDec 10, 2019

--

Wallet providers, explorers, exchanges, and staking services often use the RPC endpoints of blockchain nodes as a server for interacting with users and automating business processes. This guide will explain how to setup a server for use with the Kava REST service.

Running a Node

To setup a node, follow this guide up through the section on syncing your node. It is generally recommended that service providers run full nodes, as they often need access to historical state.

Server Setup

You can run your REST server on the same server as your node, or connect to your node from another server. If you are connecting to your node, you’ll need to open up port 26657 on your node and set the laddr to 0.0.0.0:26657 in your config.toml file.

Once you have kvd and kvcli installed on your REST server, you may want to give your server a domain name and install a reverse proxy like nginx to forward requests from the web to your REST endpoint. If you are serving directly from the REST endpoint, you will need to open port 1317 on your REST server.

To run the REST service, we will use systemd, which handles logging and restarting the REST service in case of failure. The basic service file looks like this:

[Unit]
Description=Kava REST Server
[Service]
User=kava
Group=kava
ExecStart=/home/kava/go/bin/kvcli rest-server --laddr tcp://0.0.0.0:1317 --chain-id kava-4
Restart=on-failure
TimeoutSec=120
RestartSec=30
[Install]
WantedBy=multi-user.target

Note that this assumes that the user running kvcli is named kava. Replace kava with the user name on your server if necessary. If connecting to a remote node the ExecStart command will look like:

ExecStart=/home/kava/go/bin/kvcli rest-server --laddr tcp://0.0.0.0:1317 --node <node-ip>:26657 --chain-id kava-4

Save your service file to /etc/systemd/system/kava-rest.service

To start the REST server:

sudo systemctl enable kava-rest
sudo systemctl start kava-rest

Documentation for the REST server endpoints can be found at rpc.kava.io.

--

--

Kevin Davis

I work on interledger and other cool tech in the blockchain and interoperability space for @kava-labs.