Skip to content

Sample RPCs and Responses

annak3 edited this page Apr 12, 2015 · 3 revisions

Requests

Get

{
  "id": 1164132160,
  "method": "GET",
  "params": {
	"index": 1,
	"destinationO": "FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF",
	"sourcePort": 1234,
	"sourceIP": "localhost"
  },
  "jsonrpc": "2.0"
}

Put

{
  "id": 64231991,
  "method": "PUT",
  "params": {
	"destinationO": "FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF",
	"sourcePort": 1234,
	"value": "AAAAAAAAAAAAAAAAAAAAAA==",
	"sourceIP": "localhost"
  },
  "jsonrpc": "2.0"
}

Ping

{
  "id": 704052953,
  "method": "PING",
  "params": {
	"destinationO": "FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF",
	"sourcePort": 1234,
	"sourceIP": "localhost"
  },
  "jsonrpc": "2.0"
}

Lookup

{
  "id": 307624970,
  "method": "LOOKUP",
  "params": {
	"destinationO": "FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF",
	"sourcePort": 1234,
	"sourceIP": "localhost"
  },
  "jsonrpc": "2.0"
}

Shutdown

Shutdown requests must be sent over the loopback interface. Rather than a JSON RPC response shutdowns do a quick handshake to confirm that the sender is in fact using the loopback interface and then shut down the node.

{
  "id": 222583153,
  "method": "SHUTDOWN",
  "params": {
	"destinationO": "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
	"sourcePort": 0,
	"sourceIP": "localhost"
  },
  "jsonrpc": "2.0"
}

Responses

Responses follow the JSON RPC 2.0 spec.
The result field of each successful response is a JSON object. Each contains 2 fields. Type is a one character string indicating the type of result. Result is a different type depending on the response.
Unsuccessful responses follow the JSONRPC 2.0 spec.

Error

{
  "id": null,
  "error": {
	"message": "Invalid params",
	"code": -32602
  },
  "jsonrpc": "2.0"
}

Pong

The result.result field is always the string "pong"

{  
	"id": 5,  
	"result": {  
		"result": "pong",  
		"type": "P"  
	},  
	"jsonrpc": "2.0"  
}

Value

The result.result field is a string containing Base64 encoded binary data.

{  
  "id": 5,  
  "result": {  
	"result": "AQIDBAU=",  
	"type": "V"  
  },  
  "jsonrpc": "2.0"  
}

Table

The result.result field is a JSON array representing an address table.

{  
  "id": 5,  
  "result": {  
	"result": [  
	  {  
		"port": 1234,  
		"IP": "216.58.192.14"  
	  },  
	  {  
		"port": 1236,  
		"IP": "216.58.192.14"  
	  },  
	  {  
		"port": 1235,  
		"IP": "216.58.192.14"  
	  }  
	],  
	"type": "T"  
  },  
  "jsonrpc": "2.0"  
}

Index

The result.result field for index is a JSON array of string formatted overlay addresses.

{  
  "id": 5,  
  "result": {  
	"result": [  
	  "A8:B3:E0:27:21:B9:3C:7F:1F:10:42:71:F9:13:CA:B6",  
	  "9E:5B:77:15:AB:DD:58:F1:79:BE:E5:BE:61:05:60:F2",  
	  "48:CE:24:8D:65:A8:08:BD:CA:24:37:50:9E:00:D3:93"  
	],  
	"type": "I"  
  },  
  "jsonrpc": "2.0"  
}

Ack

{  
  "id": 5,  
  "result": {  
	"result": 
	  true,  
	"type": "A"  
  },  
  "jsonrpc": "2.0"  
}

Nak

{  
  "id": 5,  
  "result": {  
	"result": 
	  false,  
	"type": "N"  
  },  
  "jsonrpc": "2.0"  
}

Note about deprecated rpc format

In a previous revision of response result schema there was no result.result and result.type, the result field just held what is now result.result. This can cause some issues if you are trying to use old things like is ValidoopResponse or if you try to pair new ResultRPCResponse objects with an old RPCHandler and/or Router.

Clone this wiki locally