API reference
Cyberd provides a JSON-RPC API. Http endpoint is served under
localhost:20657
. WebSockets are the preferred transport for cyberd RPC and are used by applications such as cyb.
Default WebSocket connection endpoint for cyberd is ws://localhost:20657/websocket
. There are test endpoints
available at http://earth.cybernode.ai:34657
and ws://earth.cybernode.ai:34657/websocket
.
Standard Methods
Query Example
Query http endpoint using curl:
curl --data '{"method":"status","params":[],"id":"1","jsonrpc":"2.0"}' \
-H "Content-Type: application/json" -X POST earth.cybernode.ai:34657
Query ws endpoint from js:
let websocket = new WebSocket("ws://earth.cybernode.ai:34657/websocket");
websocket.send(JSON.stringify({
"method":"status",
"params":[],
"id":"1",
"jsonrpc":"2.0"
}));
Method Overview
The following is an overview of the RPC methods and their current status. Click
the method name for further details such as parameter and return information.
# |
Method |
Description |
1 |
status |
Get node info, pubkey, latest block hash, app hash, block height and time. |
2 |
account |
Get account nonce, pubkey, number, and coins. |
3 |
account_bandwidth |
Get account bandwidth info for current height. |
4 |
is_link_exist |
Return true, if given link exist. |
5 |
current_bandwidth_price |
Returns current bandwidth credit price. |
6 |
index_stats |
Returns current index entities count. |
Method Details
|
|
Method |
status |
Parameters |
None |
Description |
Get node info, pubkey, latest block hash, app hash, block height and time. |
Return to Overview
|
|
|
|
Method |
account |
Parameters |
1. address (string, required)
|
Description |
Get account nonce, pubkey, number, and coins. |
Return to Overview
|
|
|
|
Method |
account_bandwidth |
Parameters |
1. address (string, required)
|
Description |
Get account bandwidth info for current height. |
Return to Overview
|
|
|
|
Method |
is_link_exist |
Parameters |
1. from (cid, required) 2. to (cid, required) 3. address (string, required)
|
Description |
Return true, if given link exist. |
Return to Overview
|
|
|
|
Method |
current_bandwidth_price |
Parameters |
None |
Description |
Returns current bandwidth credit price. |
Return to Overview
|
|
|
|
Method |
index_stats |
Parameters |
None |
Description |
Returns current index entities count. |
Return to Overview
|
|
Notifications (WebSocket-specific)
Cyberd uses standard JSON-RPC notifications to notify clients of changes, rather than requiring clients to poll cyberd
for updates. JSON-RPC notifications are a subset of requests, but do not contain an ID. The notification type
is categorized by the query
params field.
Subscribe Example
Subscribe for new blocks header from js:
let websocket = new WebSocket("ws://earth.cybernode.ai:34657/websocket");
websocket.send(JSON.stringify({
"method": "subscribe",
"params": ["tm.event='NewBlockHeader'"],
"id": "1",
"jsonrpc": "2.0"
}));
Events Overview
# |
Event |
Description |
1 |
NewBlockHeader |
Sends block header notification when a new block is committed. |
2 |
CoinsReceived |
Sends a notification when a new coins is arrived to given address. |
3 |
CoinsSend |
Sends a notification when a new coins is send from given address. |
4 |
СidsLinked |
Notification of link created by given address. |
5 |
SignedTxCommitted |
Notify when any tx for given signer is committed. |
Events Details
|
|
Event |
NewBlockHeader |
Description |
Sends block header notification when a new block is committed. |
Query |
tm.event='NewBlockHeader' |
Return to Overview
|
|
CoinsReceived
|
|
Event |
CoinsReceived |
Description |
Sends a notification when a new coins is arrived to given address. |
Query |
tm.event='EventTx' AND recipient='cbd1sk3uvpacpjm2t3389caqk4gd9n9gkzq2054yds' |
Return to Overview
|
|
CoinsSend
|
|
Event |
CoinsSend |
Description |
Sends a notification when a new coins is send from given address. |
Query |
tm.event='EventTx' AND sender='cbd1sk3uvpacpjm2t3389caqk4gd9n9gkzq2054yds' |
Return to Overview
|
|
СidsLinked
|
|
Event |
СidsLinked |
Description |
Notification of link created by given address. |
Query |
tm.event='EventTx' AND signer='cbd1sk3uvpacpjm2t3389caqk4gd9n9gkzq2054yds' AND action='link' |
Return to Overview
|
|
SignedTxCommitted
|
|
Event |
SignedTxCommitted |
Description |
Notify when any tx for given signer is committed. |
Query |
tm.event='EventTx' AND signer='cbd1sk3uvpacpjm2t3389caqk4gd9n9gkzq2054yds' |
Return to Overview
|
|