Wire Protocol # Transport # Nodes SHOULD expose an accessible JSON-RPC API. The JSON-RPC version SHOULD be 2.0. Below is an example request:
{ "jsonrpc":"2.0", "method":"get_waku_v2_debug_info", "params":[], "id":1 } Fields # Field Description jsonrpc Contains the used JSON-RPC version (Default: 2.0) method Contains the JSON-RPC method that is being called params An array of parameters for the request id The request ID Types # In this specification, the primitive types Boolean, String, Number and Null, as well as the structured types Array and Object, are to be interpreted according to the JSON-RPC specification.">
Wire Protocol # Transport # Nodes SHOULD expose an accessible JSON-RPC API. The JSON-RPC version SHOULD be 2.0. Below is an example request:
{ "jsonrpc":"2.0", "method":"get_waku_v2_debug_info", "params":[], "id":1 } Fields # Field Description jsonrpc Contains the used JSON-RPC version (Default: 2.0) method Contains the JSON-RPC method that is being called params An array of parameters for the request id The request ID Types # In this specification, the primitive types Boolean, String, Number and Null, as well as the structured types Array and Object, are to be interpreted according to the JSON-RPC specification." />
<li>Editor: Hanno Cornelius <ahref="mailto:hanno@status.im">hanno@status.im</a></li>
</ul><h1id="introduction">
Introduction
<aclass="anchor"href="#introduction">#</a>
</h1>
<p>This specification describes the JSON-RPC API that Waku v2 nodes MAY adhere to. Refer to the <ahref="/spec/10/">Waku v2 specification</a> for more information on Waku v2.</p>
<h1id="wire-protocol">
Wire Protocol
<aclass="anchor"href="#wire-protocol">#</a>
</h1>
<h2id="transport">
Transport
<aclass="anchor"href="#transport">#</a>
</h2>
<p>Nodes SHOULD expose an accessible <ahref="https://www.jsonrpc.org/specification">JSON-RPC</a> API. The JSON-RPC version SHOULD be <code>2.0</code>. Below is an example request:</p>
<td>Contains the used JSON-RPC version (<code>Default: 2.0</code>)</td>
</tr>
<tr>
<td><code>method</code></td>
<td>Contains the JSON-RPC method that is being called</td>
</tr>
<tr>
<td><code>params</code></td>
<td>An array of parameters for the request</td>
</tr>
<tr>
<td><code>id</code></td>
<td>The request ID</td>
</tr>
</tbody>
</table>
<h2id="types">
Types
<aclass="anchor"href="#types">#</a>
</h2>
<p>In this specification, the primitive types <code>Boolean</code>, <code>String</code>, <code>Number</code> and <code>Null</code>, as well as the structured types <code>Array</code> and <code>Object</code>, are to be interpreted according to the <ahref="https://www.jsonrpc.org/specification#conventions">JSON-RPC specification</a>. It also adopts the same capitalisation conventions.</p>
<p>The following structured types are defined for use throughout the document:</p>
<h3id="wakumessage">
WakuMessage
<aclass="anchor"href="#wakumessage">#</a>
</h3>
<p>Refer to <ahref="/spec/14/"><code>Waku Message</code> specification</a> for more information.</p>
<p><code>WakuMessage</code> is an <code>Object</code> containing the following fields:</p>
<td>This flag indicates the transient nature of the message. Indicates if the message is eligible to be stored by the <code>store</code> protocol, <ahref="/spec/13/">13/WAKU2-STORE</a>.</td>
</tr>
</tbody>
</table>
<h2id="method-naming">
Method naming
<aclass="anchor"href="#method-naming">#</a>
</h2>
<p>The JSON-RPC methods in this document are designed to be mappable to HTTP REST endpoints. Method names follow the pattern <code><method_type>_waku_<protocol_version>_<api>_<api_version>_<resource></code></p>
<ul>
<li><code><method_type></code>: prefix of the HTTP method type that most closely matches the JSON-RPC function. Supported <code>method_type</code> values are <code>get</code>, <code>post</code>, <code>put</code>, <code>delete</code> or <code>patch</code>.</li>
<li><code><protocol_version></code>: Waku version. Currently <strong>v2</strong>.</li>
<li><code><api></code>: one of the listed APIs below, e.g. <code>store</code>, <code>debug</code>, or <code>relay</code>.</li>
<li><code><api_version></code>: API definition version. Currently <strong>v1</strong> for all APIs.</li>
<li><code><resource></code>: the resource or resource path being addressed</li>
</ul>
<p>The method <code>post_waku_v2_relay_v1_message</code>, for example, would map to the HTTP REST endpoint <code>POST /waku/v2/relay/v1/message</code>.</p>
<h2id="debug-api">
Debug API
<aclass="anchor"href="#debug-api">#</a>
</h2>
<h3id="types-1">
Types
<aclass="anchor"href="#types-1">#</a>
</h3>
<p>The following structured types are defined for use on the Debug API:</p>
<h4id="wakuinfo">
WakuInfo
<aclass="anchor"href="#wakuinfo">#</a>
</h4>
<p><code>WakuInfo</code> is an <code>Object</code> containing the following fields:</p>
<p>The <code>get_waku_v2_debug_v1_version</code> method retrieves the version of a Waku v2 node as a string.
The version SHOULD follow <ahref="https://semver.org/">semantic versioning</a>.
In case the node’s current build is based on a git commit between semantic versions,
the retrieved version string MAY contain the git commit hash alone or in combination with the latest semantic version.</p>
<h4id="parameters-1">
Parameters
<aclass="anchor"href="#parameters-1">#</a>
</h4>
<p>none</p>
<h4id="response-1">
Response
<aclass="anchor"href="#response-1">#</a>
</h4>
<ul>
<li><strong><code>string</code></strong> - represents the version of a Waku v2 node</li>
</ul>
<h2id="relay-api">
Relay API
<aclass="anchor"href="#relay-api">#</a>
</h2>
<p>Refer to the <ahref="https://github.com/vacp2p/specs/blob/master/specs/waku/v2/waku-relay.md">Waku Relay specification</a> for more information on the relaying of messages.</p>
<h3id="types-2">
Types
<aclass="anchor"href="#types-2">#</a>
</h3>
<p>The following structured types are defined for use on the Relay API:</p>
<h4id="wakurelaymessage">
WakuRelayMessage
<aclass="anchor"href="#wakurelaymessage">#</a>
</h4>
<p><code>WakuRelayMessage</code> is an <code>Object</code> containing the following fields:</p>
<td>This flag indicates the transient nature of the message.</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong><em>NOTE:</em></strong><code>WakuRelayMessage</code> maps directly to a <ahref="#wakumessage"><code>WakuMessage</code></a>, except that the latter contains an explicit message <code>version</code>. For <code>WakuRelay</code> purposes, the versioning is handled by the API.</p>
<p>The <code>post_waku_v2_relay_v1_message</code> method publishes a message to be relayed on a <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a></p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> being published on</td>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>post_waku_v2_relay_v1_subscriptions</code> method subscribes a node to an array of <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topics</code></a>.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topics</code></a> being subscribed to</td>
</tr>
</tbody>
</table>
<h4id="response-3">
Response
<aclass="anchor"href="#response-3">#</a>
</h4>
<ul>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>delete_waku_v2_relay_v1_subscriptions</code> method unsubscribes a node from an array of <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topics</code></a>.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topics</code></a> being unsubscribed from</td>
</tr>
</tbody>
</table>
<h4id="response-4">
Response
<aclass="anchor"href="#response-4">#</a>
</h4>
<ul>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>get_waku_v2_relay_v1_messages</code> method returns a list of messages that were received on a subscribed <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> after the last time this method was called. The server MUST respond with an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> if no subscription exists for the polled <code>topic</code>. If no message has yet been received on the polled <code>topic</code>, the server SHOULD return an empty list. This method can be used to poll a <code>topic</code> for new messages.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> to poll for the latest messages</td>
</tr>
</tbody>
</table>
<h4id="response-5">
Response
<aclass="anchor"href="#response-5">#</a>
</h4>
<ul>
<li><strong><code>Array</code>[<ahref="#wakumessage"><code>WakuMessage</code></a>]</strong> - the latest <code>messages</code> on the polled <code>topic</code> or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
</ul>
<h2id="store-api">
Store API
<aclass="anchor"href="#store-api">#</a>
</h2>
<p>Refer to the <ahref="https://github.com/vacp2p/specs/blob/master/specs/waku/v2/waku-store.md">Waku Store specification</a> for more information on message history retrieval.</p>
<h3id="types-3">
Types
<aclass="anchor"href="#types-3">#</a>
</h3>
<p>The following structured types are defined for use on the Store API:</p>
<h4id="storeresponse">
StoreResponse
<aclass="anchor"href="#storeresponse">#</a>
</h4>
<p><code>StoreResponse</code> is an <code>Object</code> containing the following fields:</p>
<td>Message <ahref="#Index"><code>Index</code></a> from which to perform pagination. If not included and <code>forward</code> is set to <code>true</code>, paging will be performed from the beginning of the list. If not included and <code>forward</code> is set to <code>false</code>, paging will be performed from the end of the list.</td>
<p>The <code>get_waku_v2_store_v1_messages</code> method retrieves historical messages on specific content topics. This method MAY be called with <ahref="#pagingoptions"><code>PagingOptions</code></a>, to retrieve historical messages on a per-page basis. If the request included <ahref="#pagingoptions"><code>PagingOptions</code></a>, the node MUST return messages on a per-page basis and include <ahref="#pagingoptions"><code>PagingOptions</code></a> in the response. These <ahref="#pagingoptions"><code>PagingOptions</code></a> MUST contain a <code>cursor</code> pointing to the <ahref="#Index"><code>Index</code></a> from which a new page can be requested.</p>
<td>The inclusive lower bound on the <ahref="/spec/14#Payloads"><code>timestamp</code></a> of queried <ahref="#wakumessage"><code>WakuMessage</code>s</a>. This field holds the Unix epoch time in nanoseconds as a 64-bits integer value.</td>
<td>The inclusive upper bound on the <ahref="/spec/14#Payloads"><code>timestamp</code></a> of queried <ahref="#wakumessage"><code>WakuMessage</code>s</a>. This field holds the Unix epoch time in nanoseconds as a 64-bits integer value.</td>
<li><ahref="#storeresponse"><strong><code>StoreResponse</code></strong></a> - the response to a <code>query</code> for historical messages.</li>
</ul>
<h2id="filter-api">
Filter API
<aclass="anchor"href="#filter-api">#</a>
</h2>
<p>Refer to the <ahref="https://github.com/vacp2p/specs/blob/master/specs/waku/v2/waku-filter.md">Waku Filter specification</a> for more information on content filtering.</p>
<h3id="types-4">
Types
<aclass="anchor"href="#types-4">#</a>
</h3>
<p>The following structured types are defined for use on the Filter API:</p>
<h4id="contentfilter-1">
ContentFilter
<aclass="anchor"href="#contentfilter-1">#</a>
</h4>
<p><code>ContentFilter</code> is an <code>Object</code> containing the following fields:</p>
<p>The <code>post_waku_v2_filter_v1_subscription</code> method creates a subscription in a <ahref="https://github.com/vacp2p/specs/blob/master/specs/waku/v2/waku-filter.md#rationale">light node</a> for messages that matches a content filter and, optionally, a <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a>.</p>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>delete_waku_v2_filter_v1_subscription</code> method removes subscriptions in a <ahref="https://github.com/vacp2p/specs/blob/master/specs/waku/v2/waku-filter.md#rationale">light node</a> matching a content filter and, optionally, a <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a>.</p>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>get_waku_v2_filter_v1_messages</code> method returns a list of messages that were received on a subscribed content <code>topic</code> after the last time this method was called. The server MUST respond with an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> if no subscription exists for the polled content <code>topic</code>. If no message has yet been received on the polled content <code>topic</code>, the server SHOULD respond with an empty list. This method can be used to poll a content <code>topic</code> for new messages.</p>
<td>The content topic to poll for the latest messages</td>
</tr>
</tbody>
</table>
<h4id="response-9">
Response
<aclass="anchor"href="#response-9">#</a>
</h4>
<ul>
<li><strong><code>Array</code>[<ahref="#wakumessage"><code>WakuMessage</code></a>]</strong> - the latest <code>messages</code> on the polled content <code>topic</code> or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
</ul>
<h2id="admin-api">
Admin API
<aclass="anchor"href="#admin-api">#</a>
</h2>
<p>The Admin API provides privileged accesses to the internal operations of a Waku v2 node.</p>
<h3id="types-5">
Types
<aclass="anchor"href="#types-5">#</a>
</h3>
<p>The following structured types are defined for use on the Admin API:</p>
<h4id="wakupeer">
WakuPeer
<aclass="anchor"href="#wakupeer">#</a>
</h4>
<p><code>WakuPeer</code> is an <code>Object</code> containing the following fields:</p>
<p>The <code>get_waku_v2_admin_v1_peers</code> method returns an array of peers registered on this node. Since a Waku v2 node may open either continuous or ad hoc connections, depending on the negotiated protocol, these peers may have different connected states. The same peer MAY appear twice in the returned array, if it is registered for more than one protocol.</p>
<h4id="parameters-10">
Parameters
<aclass="anchor"href="#parameters-10">#</a>
</h4>
<p>none</p>
<h4id="response-10">
Response
<aclass="anchor"href="#response-10">#</a>
</h4>
<ul>
<li><strong><code>Array</code>[<ahref="#WakuPeer"><code>WakuPeer</code></a>]</strong> - Array of peers registered on this node</li>
<td>Array of peer <code>multiaddrs</code> to connect to. Each <code>multiaddr</code> must contain the <ahref="https://docs.libp2p.io/concepts/addressing/">location and identity addresses</a> of a peer.</td>
</tr>
</tbody>
</table>
<h4id="response-11">
Response
<aclass="anchor"href="#response-11">#</a>
</h4>
<ul>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
</ul>
<h2id="private-api">
Private API
<aclass="anchor"href="#private-api">#</a>
</h2>
<p>The Private API provides functionality to encrypt/decrypt <code>WakuMessage</code> payloads using either symmetric or asymmetric cryptography. This allows backwards compatibility with <ahref="https://github.com/vacp2p/specs/blob/master/specs/waku/v1/waku-1.md">Waku v1 nodes</a>.
It is the API client’s responsibility to keep track of the keys used for encrypted communication. Since keys must be cached by the client and provided to the node to encrypt/decrypt payloads, a Private API SHOULD NOT be exposed on non-local or untrusted nodes.</p>
<h3id="types-6">
Types
<aclass="anchor"href="#types-6">#</a>
</h3>
<p>The following structured types are defined for use on the Private API:</p>
<h4id="keypair">
KeyPair
<aclass="anchor"href="#keypair">#</a>
</h4>
<p><code>KeyPair</code> is an <code>Object</code> containing the following fields:</p>
<p>The <code>post_waku_v2_private_v1_symmetric_message</code> method publishes a message to be relayed on a <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a>.</p>
<p>Before being relayed, the message payload is encrypted using the supplied symmetric key. The client MUST provide a symmetric key.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> being published on</td>
<td>The hex encoded symmetric key to use for payload encryption. This field MUST be included if symmetric key cryptography is selected</td>
</tr>
</tbody>
</table>
<h4id="response-14">
Response
<aclass="anchor"href="#response-14">#</a>
</h4>
<ul>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>post_waku_v2_private_v1_asymmetric_message</code> method publishes a message to be relayed on a <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a>.</p>
<p>Before being relayed, the message payload is encrypted using the supplied public key. The client MUST provide a public key.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> being published on</td>
<td>The hex encoded public key to use for payload encryption. This field MUST be included if asymmetric key cryptography is selected</td>
</tr>
</tbody>
</table>
<h4id="response-15">
Response
<aclass="anchor"href="#response-15">#</a>
</h4>
<ul>
<li><strong><code>Bool</code></strong> - <code>true</code> on success or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>get_waku_v2_private_v1_symmetric_messages</code> method decrypts and returns a list of messages that were received on a subscribed <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> after the last time this method was called. The server MUST respond with an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> if no subscription exists for the polled <code>topic</code>. If no message has yet been received on the polled <code>topic</code>, the server SHOULD return an empty list. This method can be used to poll a <code>topic</code> for new messages.</p>
<p>Before returning the messages, the server decrypts the message payloads using the supplied symmetric key. The client MUST provide a symmetric key.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> to poll for the latest messages</td>
<td>The hex encoded symmetric key to use for payload decryption. This field MUST be included if symmetric key cryptography is selected</td>
</tr>
</tbody>
</table>
<h4id="response-16">
Response
<aclass="anchor"href="#response-16">#</a>
</h4>
<ul>
<li><strong><code>Array</code>[<ahref="#wakurelaymessage"><code>WakuRelayMessage</code></a>]</strong> - the latest <code>messages</code> on the polled <code>topic</code> or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>The <code>get_waku_v2_private_v1_asymmetric_messages</code> method decrypts and returns a list of messages that were received on a subscribed <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> after the last time this method was called. The server MUST respond with an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> if no subscription exists for the polled <code>topic</code>. If no message has yet been received on the polled <code>topic</code>, the server SHOULD return an empty list. This method can be used to poll a <code>topic</code> for new messages.</p>
<p>Before returning the messages, the server decrypts the message payloads using the supplied private key. The client MUST provide a private key.</p>
<td>The <ahref="https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor">PubSub <code>topic</code></a> to poll for the latest messages</td>
<td>The hex encoded private key to use for payload decryption. This field MUST be included if asymmetric key cryptography is selected</td>
</tr>
</tbody>
</table>
<h4id="response-17">
Response
<aclass="anchor"href="#response-17">#</a>
</h4>
<ul>
<li><strong><code>Array</code>[<ahref="#wakurelaymessage"><code>WakuRelayMessage</code></a>]</strong> - the latest <code>messages</code> on the polled <code>topic</code> or an <ahref="https://www.jsonrpc.org/specification#error_object">error</a> on failure.</li>
<p>This method is part of the <code>store</code> API and the specific resources to retrieve are (historical) <code>messages</code>. The protocol (<code>waku</code>) is on <code>v2</code>, whereas the Store API definition is on <code>v1</code>.</p>
<ol>
<li><code>get</code><em>all</em> the historical messages for content topic <strong>"/waku/2/default-content/proto"</strong>; no paging required</li>
<li><code>get</code> a single page of historical messages for content topic <strong>"/waku/2/default-content/proto"</strong>; 2 messages per page, backward direction. Since this is the initial query, no <code>cursor</code> is provided, so paging will be performed from the end of the list.</li>
<li><code>get</code> the next page of historical messages for content topic <strong>"/waku/2/default-content/proto"</strong>, using the cursor received above; 2 messages per page, backward direction.</li>