2025-06-17 19:47:29 +10:00
---
2025-06-30 14:39:30 +10:00
title: WAKU-API
name: Waku API definition
2025-06-17 19:47:29 +10:00
category: Standards Track
tags: [reliability, application, api, protocol composition]
editor: Oleksandr Kozlov < oleksandr @status .im >
contributors:
- Oleksandr Kozlov < oleksandr @status .im >
- Prem Chaitanya Prathi < prem @status .im >
- Franck Royer < franck @status .im >
---
## Table of contents
2025-06-18 16:34:21 +10:00
TODO
2025-06-17 19:47:29 +10:00
## Abstract
This document specifies an Application Programming Interface (API) that is RECOMMENDED for developers of the [WAKU2 ](https://github.com/vacp2p/rfc-index/blob/7b443c1aab627894e3f22f5adfbb93f4c4eac4f6/waku/standards/core/10/waku2.md ) clients to implement,
and for consumers to use as a single entry point to its functionalities.
This API defines the RECOMMENDED interface for leveraging Waku protocols to send and receive messages.
Application developers SHOULD use it to access capabilities for peer discovery, message routing, and peer-to-peer reliability.
## Motivation
The accessibility of Waku protocols is capped by the accessibility of their implementations, and hence API.
2025-06-24 12:23:12 +10:00
This RFC enables a concerted effort to draft an API that is simple and accessible, and provides an opinion on sane defaults.
2025-06-17 19:47:29 +10:00
2025-06-24 12:23:12 +10:00
The API defined in this document is an opinionated-by-purpose method to use the more agnostic [WAKU2]() protocols.
2025-06-17 19:47:29 +10:00
## Syntax
The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
“RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC2119 ](https://www.ietf.org/rfc/rfc2119.txt ).
## API design
### IDL
A custom Interface Definition Language (IDL) in YAML is used to define the Waku API.
Existing IDL Such as OpenAPI, AsyncAPI or WIT do not exactly fit the requirements for this API.
Hence, instead of having the reader learn a new IDL, we propose to use a simple IDL with self-describing syntax.
An alternative would be to choose a programming language. However, such choice may express unintended opinions on the API.
2025-06-30 15:25:12 +10:00
### Primitive types and general guidelines
2025-06-17 19:47:29 +10:00
2025-09-11 15:51:13 +10:00
- No `default` means that the value is mandatory, meaning a `default` value implies an optional parameter.
2025-06-24 12:23:12 +10:00
- Primitive types are `string` , `int` , `bool` , `enum` and `uint`
- Complex pre-defined types are:
2025-06-30 15:25:12 +10:00
- `struct` : object and other nested types.
- `array` : iterable object containing values of all the same type.
- `result` : an enum type that either contain a return value (success), or an error (failure); The error is left to the implementor.
2025-06-24 13:03:22 +10:00
- `error` : Left to the implementor on whether `error` types are `string` or `object` in the given language.
2025-06-30 15:25:12 +10:00
- Usage of `result` is RECOMMENDED, usage of exceptions is NOT RECOMMENDED, no matter the language.
2025-06-17 19:47:29 +10:00
2025-06-30 15:25:12 +10:00
### Language mappings
2025-06-18 16:34:21 +10:00
How the API definition should be translated to specific languages.
```yaml
language_mappings:
2025-06-30 14:26:25 +10:00
typescript:
2025-06-18 16:34:21 +10:00
naming_convention:
2025-06-30 14:26:25 +10:00
- functions: "camelCase"
- variables: "camelCase"
2025-06-18 16:34:21 +10:00
- types: "PascalCase"
2025-06-30 14:26:25 +10:00
nim:
2025-06-18 16:34:21 +10:00
naming_convention:
- functions: "camelCase"
- variables: "camelCase"
- types: "PascalCase"
```
2025-06-30 15:25:12 +10:00
### Application
This API is designed for generic use and ease across all programming languages, for `edge` and `relay` type nodes.
## The Waku API
```yaml
api_version: "0.0.1"
library_name: "waku"
description: "Waku: a private and censorship-resistant message routing library."
```
### Initialise Waku node
2025-06-17 19:47:29 +10:00
2025-06-30 15:25:12 +10:00
#### Type definitions
2025-06-17 19:47:29 +10:00
```yaml
types:
2025-06-24 13:03:22 +10:00
WakuNode:
type: struct
description: "A Waku node instance."
2025-08-05 15:28:46 +10:00
2025-09-12 13:40:54 +10:00
NodeConfig:
2025-06-17 19:47:29 +10:00
type: struct
fields:
2025-08-05 15:28:46 +10:00
mode:
2025-06-17 19:47:29 +10:00
type: string
2025-08-05 15:28:46 +10:00
constraints: [ "edge", "relay" ]
2025-09-15 15:31:50 +10:00
default: "_platform dependent_"
2025-06-17 19:47:29 +10:00
description: "The mode of operation of the Waku node. Core protocols used by the node are inferred from this mode."
2025-09-12 13:40:54 +10:00
waku_config:
type: WakuConfig
2025-06-17 19:47:29 +10:00
default: TheWakuNetworkPreset
store_confirmation:
2025-09-11 15:51:13 +10:00
type: bool
2025-08-05 15:27:48 +10:00
# Until further dogfooding, assuming default false, usage of SDS should be preferred
2025-06-17 19:47:29 +10:00
default: false
2025-09-09 13:24:26 +10:00
description: "No-payload store hash queries are made to confirm whether outbound messages were received by remote store node."
2025-09-15 15:31:50 +10:00
networking_config:
type: NetworkConfig
default: DefaultNetworkingConfig
2025-09-10 14:19:52 +10:00
eth_rpc_endpoints:
type: array< string >
description: "Eth/Web3 RPC endpoint URLs"
2025-06-24 12:43:11 +10:00
2025-09-12 13:40:54 +10:00
WakuConfig:
2025-06-24 12:43:11 +10:00
type: struct
fields:
2025-09-15 15:31:50 +10:00
remote_nodes:
2025-06-24 12:43:11 +10:00
type: array< string >
2025-09-15 15:31:50 +10:00
# Default means the node does not bootstrap, e.g. for local development
default: []
description: "Nodes to connect to; used for discovery bootstrapping and quick connectivity. entree and multiaddr formats are accepted."
2025-06-24 12:43:11 +10:00
static_store_nodes:
type: array< string >
2025-09-12 17:40:23 +10:00
default: []
2025-06-24 12:43:11 +10:00
description: "Only the passed nodes are used for store queries, discovered store nodes are discarded."
cluster_id:
type: uint
auto_sharding_config:
2025-09-11 15:51:13 +10:00
type: AutoShardingConfig
2025-08-05 15:27:48 +10:00
default: DefaultAutoShardingConfig
2025-08-05 15:28:46 +10:00
description: "The auto-sharding config, if sharding mode is `auto` "
2025-08-06 16:15:40 +10:00
message_validation:
type: MessageValidation
# If the default config for TWN is not used, then we still provide a message validation default
default: DefaultMessageValidation
2025-06-24 12:43:11 +10:00
2025-09-15 15:31:50 +10:00
NetworkingConfig:
type: string
fields:
listen_address:
# Is not applicable in some environments such as browser.
type: string
default: "0.0.0.0"
description: "The network IP address on which libp2p and discv5 listen for inbound connections"
p2p_tcp_port:
# Is not applicable in non-TCP environments such as browser
type: uint
default: 60000
description: "The TCP port used for libp2p, relay, aka, general p2p message routing."
discv5_udp_port:
# Is not applicable in non-UDP environments such as browser
type: uint
default: 9000
description: "The UDP port used for discv5."
2025-06-17 19:47:29 +10:00
AutoShardingConfig:
type: struct
fields:
2025-08-05 15:28:46 +10:00
num_shards_in_cluster:
2025-06-17 19:47:29 +10:00
type: uint
description: "The number of shards in the configured cluster; this is a globally agreed value for each cluster."
2025-08-06 16:15:40 +10:00
MessageValidation:
type: struct
fields:
max_message_size_bytes:
type: uint
default: 153600 # 150 KiB
description: "The maximum accepted message size in Bytes"
# For now, RLN is the only message validation available
rln_config:
2025-09-11 15:51:13 +10:00
type: RlnConfig
2025-08-06 16:15:40 +10:00
# If the default config for TWN is not used, then we do not apply RLN
default: none
RlnConfig:
type: struct
fields:
contract_address:
type: string
description: "The address of the RLN contract exposes `root` and `getMerkleRoot` ABIs"
chain_id:
type: uint
description: "The chain id on which the RLN contract is deployed"
epoch_size_sec:
type: uint
description: "The epoch size to use for RLN, in seconds"
2025-06-17 19:47:29 +10:00
```
2025-06-30 15:25:12 +10:00
#### Function definitions
2025-06-17 19:47:29 +10:00
```yaml
functions:
2025-09-09 14:49:12 +10:00
createNode:
2025-06-24 13:03:22 +10:00
description: "Initialise a Waku node instance"
2025-06-17 19:47:29 +10:00
parameters:
2025-06-24 13:03:22 +10:00
- name: config
type: Config
description: "The Waku node configuration."
2025-06-17 19:47:29 +10:00
returns:
2025-06-24 13:03:22 +10:00
type: result< WakuNode , error >
2025-06-17 19:47:29 +10:00
```
2025-06-30 15:25:12 +10:00
#### Predefined values
2025-06-24 12:43:11 +10:00
```yaml
values:
2025-06-30 15:25:12 +10:00
2025-09-15 15:31:50 +10:00
DefaultNetworkingConfig:
type: NetworkConfig
fields:
listen_address: "0.0.0.0"
p2p_tcp_port: 60000
discv5_udp_port: 9000
2025-06-24 12:43:11 +10:00
TheWakuNetworkPreset:
2025-09-12 13:40:54 +10:00
type: WakuConfig
2025-06-24 12:43:11 +10:00
fields:
2025-09-15 15:31:50 +10:00
remote_nodes: [ "enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox .waku.nodes.status.im" ]
2025-06-24 12:43:11 +10:00
static_store_nodes: #TODO: enter sandbox store nodes multiaddr
cluster_id: 1
2025-08-06 16:15:40 +10:00
auto_sharding_config:
fields:
numShardsInCluster: 8
2025-09-10 14:15:23 +10:00
message_validation: TheWakuNetworkMessageValidation
2025-06-30 15:25:12 +10:00
2025-08-06 16:15:40 +10:00
TheWakuNetworkMessageValidation:
type: MessageValidation
2025-06-24 12:43:11 +10:00
fields:
2025-08-06 16:15:40 +10:00
max_message_bytes_uint: 153600 # 150 KiB
rln_config:
fields:
contract_address: "0xB9cd878C90E49F797B4431fBF4fb333108CB90e6"
chain_id: 59141
epoch_size_sec: 600 # 10 minutes
# If not preset is used, autosharding on one cluster is applied by default
# This is a safe default that abstract shards (content topic shard derivation), and it enables scaling at a later stage
2025-08-05 15:27:48 +10:00
DefaultAutoShardingConfig:
type: AutoShardingConfig
fields:
2025-08-05 15:28:46 +10:00
num_shards_in_cluster: 1
2025-08-06 16:15:40 +10:00
# If no preset is used, we only apply a max size limit to messages
DefaultMessageValidation:
type: MessageValidation
fields:
max_message_bytes_uint: 153600 # 150 KiB
rln_config: none
2025-06-24 12:43:11 +10:00
```
2025-06-30 15:25:12 +10:00
#### Extended definitions
If the `mode` set is `edge` , the initialised `WakuNode` MUST mount:
- [LIGHTPUSH ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/19/lightpush.md ) as client
- [FILTER ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/12/filter.md ) as client
- [STORE ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/13/store.md ) as client
And must use mount and use the following protocols to discover peers:
- [PEER-EXCHANGE ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/34/peer-exchange.md )
If the `mode` set is `relay` , the initialised `WakuNode` MUST mount:
- [RELAY ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/11/relay.md )
- [LIGHTPUSH ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/19/lightpush.md ) as service node
- [FILTER ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/12/filter.md ) as service node
- [PEER-EXCHANGE ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/34/peer-exchange.md ) as service node
- [STORE ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/13/store.md ) as client
And must use mount and use the following protocols to discover peers:
- [DISCV5 ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/33/discv5.md )
- [PEER-EXCHANGE ](https://github.com/vacp2p/rfc-index/blob/main/waku/standards/core/34/peer-exchange.md )
- [RENDEZVOUS ](https://github.com/waku-org/specs/blob/master/standards/core/rendezvous.md )
`edge` mode SHOULD be used if node functions in resource restricted environment,
whereas `relay` SHOULD be used if node has no strong hardware or bandwidth restrictions.
2025-07-21 22:07:14 +10:00
## The Validation API
2025-06-30 15:25:12 +10:00
2025-07-21 22:07:14 +10:00
[RLN Relay]() is currently the primary message validation mechanism in place.
Work is scheduled to specify a validate API to enable plug-in validation.
As part of this API, it will be expected that an validation object can be passed,
that would contain all validation parameters including RLN.
In the time being, we
2025-06-30 15:25:12 +10:00
2025-06-17 19:47:29 +10:00
## Security/Privacy Considerations
See [WAKU2-ADVERSARIAL-MODELS ](https://github.com/waku-org/specs/blob/master/informational/adversarial-models.md ).
## Copyright
Copyright and related rights waived via [CC0 ](https://creativecommons.org/publicdomain/zero/1.0/ ).