RecordsKeeper offers a solution where you can publish your data in key-value based pairs over the RecordsKeeper Blockchain and then retrieve it using the key. In this post, we will show you how to use curl commands in the shell to publish and retrieve data records from the streams in RecordsKeeper Blockchain.

Before we start you need to set up your own node by following this documentation: https://docs.recordskeeper.co/en/latest/gettingstarted.html

You also need the proper authorization for your node. You have to provide Base64 conversion of node’s Username and Password, which you can access through RK.conf built in your RecordsKeeper directory. Check below to get the Username and Password for your node and then convert them into Basic Authorization in Base64 using any tool.

Linux (Ubuntu):
From your terminal run following commands:

cd ~/.rk/recordskeeper/
cat rk.conf

It will open the configuration file from where you can copy rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Windows:
Go to the directory:
AppData > Roaming > Rk > RecordsKeeper

Then look for the rk.conf file and open it in any text editor. It will display rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Let’s start with How to publish your data in a stream:
RecordsKeeper offers a solution where you can publish your data in key-value based pairs over the RecordsKeeper Blockchain and then retrieve it using the key. In this post, we will show you how to use curl commands in the shell to publish and retrieve data records from the streams in RecordsKeeper Blockchain.

Before we start you need to set up your own node by following this documentation: https://docs.recordskeeper.co/en/latest/gettingstarted.html

You also need the proper authorization for your node. You have to provide Base64 conversion of node’s Username and Password, which you can access through rk.conf built in your RecordsKeeper directory. Check below to get the Username and Password for your node and then convert them into Basic Authorization in Base64 using any tool.

Linux (Ubuntu):
From your terminal run following commands:

cd ~/.rk/recordskeeper/
cat rk.conf

It will open the configuration file from where you can copy rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Windows:
Go to the directory:
AppData > Roaming > Rk > RecordsKeeper

Then look for the rk.conf file and open it in any text text editor. It will display rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Let’s start with How to publish your data in a stream:

Publish

You can use the publish command which is provided as JSON RPC API to publish the data over the RecordsKeeper Blockchain

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

 -d ‘{“method”:”publish”,”params”:[“root”, “testkey1”, “787676”],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

 

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the transaction id which can be see through RecordsKeeper Blockchain explorer. Here we are showing you the example to publish to the RecordsKeeper Testnet, you can also use the same steps to publish over the RecordsKeeper Mainnet.

Retrieve

Get Stream Item

You can use this command to get the exact stream item from the RecordsKeeper Blockchain. You need to pass the stream name and transaction id as the parameters.

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

 -d ‘{“method”:”getstreamitem”,”params”:[“root”, “43878d92e64077d300e70d6e7e99914a8b4732b513ce0f35fbb26fe4a7a5b37e”],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the exact details about the stream item published over the RecordsKeeper Blockchain

List Stream Key Items

You can use this command to list the value against the key stored in the stream over the RecordsKepper Blockchain. You need to pass the stream name and the key for the data as the parameters.

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

 -d ‘{“method”:”liststreamkeyitems”,”params”:[“root”, “testkey1″],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the data corresponding to the key stored in the stream item published over the RecordsKeeper Blockchain.

List Stream Items

This command is used to list all the stream items inside a single stream. By passing the stream name you can get all the records stored inside the specific stream.

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

  -d ‘{“method”:”liststreamitems”,”params”:[“root”],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the JSON object with all the records inside a single stream.

Curl commands are very effective to make JSON RPC calls, you can also use any programming language to create a request for the RecordsKeeper Blockchain. If you are not familiar with Curl then you can directly see the stream details and stream items through the RecordsKeeper Blockchain Explorer (https://www.recordskeeper.co/blog/use-recordskeeper-blockchain-explorer/)