API
How To
This section provides instructions on how to perform common requests on rings JSON-RPC API endpoints.
Make requests
curl
Url curl
to make the requests.
javascript
TODO
JSON-RPC methods
This section lists the rings JSON-RPC API endpoints. You can call these APIs using a variety of tools.
Error codes
The follow list contains all possible error codes and associated messages:
-32000
Internal service error
standard
-32001
Connect remote server with error occurred
standard
-32002
Push or find pending transport failed
standard
-32003
Transport not found
standard
-32004
Create new transport
failed
standard
-32005
Close transport
failed
standard
-32006
Encode data error
standard
-32007
Decode data error
standard
-32008
Register ice failed
standard
-32009
Create new offer
failed
standard
-32010
Create new answder
failed
standard
-32011
Invalid transport id
standard
-32012
Invalid did
standard
-32013
Invalid method
standard
-32014
Send message with error occurred
standard
-32015
Permission requires to do something
standard
-32016
VNode action error
standard
-32017
Register service with error occurred
standard
-32018
Invalid data
standard
-32019
Invalid message
standard
-32020
Invalid service
standard
-32021
Invalid address
standard
-32022
Invalid auth data
standard
Example error response:
nodeInfo
return rings node basic information.
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
EXAMPLE
RESPONSE
version
- current running node version
BODY
connectPeerViaHttp
Connect a peer with peer's jsonrpc endpoint
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
EXAMPLE
RESPONSE
transport_did
- the id of transport
EXAMPLE
connectWithDid
Connect a peer with peer's did
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
EXAMPLE
connectWithSeed
Connect a peer with peer's seed
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
EXAMPLE
createOffer
Create an offer for connection
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
transport_id
: id of the transportice
: ice message
EXAMPLE
answerOffer
Answer an offer for connection
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
transport_id
: id of the transportice
: ice message
EXAMPLE
listPeers
List all node connected peers
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
peers
- list of connected peerstransport_id
- id of the transportdid
- did of remote peerstate
- transport state
EXAMPLE
closeConnection
Close a connected connection with the did of peer
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
EXAMPLE
listPendings
List all pending connections
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
transport_infos
- list of all pending transportstransport_id
- id of the transportstate
- state of the transport
EXAMPLE
closePendingTransport
Close a specific pending transport
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
EXAMPLE
sendHttpRequestMessage
Send a http request message to remote peer, the remote peer should provide the service you want to use
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
HTTP-REQUEST-ARG
name
- service namemethod
- http methodpath
- resource pathtimeout
- timeout of remote request, optionalheaders
- remote request with headers, optionalbody
- request body what you want to send to remote service, optional
RESPONSE
tx_id
- transaction id
EXAMPLE
sendSimpleTextMessage
Send simple text message to a peer
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
tx_id
- transaction id
EXAMPLE
sendCustomMessage
Send custom message to a peer
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
tx_id
- transaction id
EXAMPLE
publishMessageToTopic
Publish data message to specific topic
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
EXAMPLE
fetchMessageToTopic
Fetch message from specific topic
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
MESSAGES - message vec of specific topic
EXAMPLE
registerService
Register custom service to rings network
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
EXAMPLE
lookupService
Lookup custom service from rings network, you can find all dids of node which provide service you want.
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
DIDS - did list of nodes which provide service with specific name
EXAMPLE
pollMessage
Use this method, you can pull messages received by this node, to provide your custom service, But we suggest use websocket
endpoint realtime get messages.
REQUEST
POST http://127.0.0.1:50000
HEADERS
Content-Type: application/json
X-SIGNATURE: YOUR-SIGNATURE
EXAMPLE
RESPONSE
message - custom message received
EXAMPLE
Last updated