2020-07-20 10:01:49 +00:00
|
|
|
# Waku APIs
|
2020-07-07 04:54:31 +00:00
|
|
|
|
|
|
|
## Nim API
|
|
|
|
|
2020-07-27 09:01:06 +00:00
|
|
|
The Nim Waku API consist of five methods. Some of them have different arity
|
|
|
|
depending on what privacy/bandwidth trade-off the consumer wants to make. These
|
|
|
|
five method are:
|
2020-07-07 04:54:31 +00:00
|
|
|
|
2020-07-27 09:01:06 +00:00
|
|
|
1. **Init** - create and start a node.
|
|
|
|
2. **Subscribe** - to a topic or a specific content filter.
|
|
|
|
3. **Unsubscribe** - to a topic or a specific content filter.
|
|
|
|
4. **Publish** - to a topic, or a topic and a specific content filter.
|
|
|
|
5. **Query** - for historical messages.
|
2020-07-20 10:01:49 +00:00
|
|
|
|
|
|
|
```Nim
|
2020-07-28 10:28:32 +00:00
|
|
|
proc init*(T: type WakuNode, conf: WakuNodeConf): Future[T]
|
2020-07-27 09:01:06 +00:00
|
|
|
## Creates and starts a Waku node.
|
|
|
|
##
|
2020-07-28 08:06:00 +00:00
|
|
|
## Status: Implemented.
|
2020-07-27 09:01:06 +00:00
|
|
|
|
|
|
|
method subscribe*(w: WakuNode, topic: Topic, handler: TopicHandler)
|
|
|
|
## Subscribes to a PubSub topic. Triggers handler when receiving messages on
|
2020-08-27 10:15:46 +00:00
|
|
|
## this topic. TopicHandler is a method that takes a topic and some data.
|
2020-07-27 09:01:06 +00:00
|
|
|
##
|
2020-08-27 10:15:46 +00:00
|
|
|
## NOTE The data field SHOULD be decoded as a WakuMessage.
|
|
|
|
## Status: Implemented.
|
2020-07-27 09:01:06 +00:00
|
|
|
|
|
|
|
method subscribe*(w: WakuNode, contentFilter: ContentFilter, handler: ContentFilterHandler)
|
|
|
|
## Subscribes to a ContentFilter. Triggers handler when receiving messages on
|
|
|
|
## this content filter. ContentFilter is a method that takes some content
|
|
|
|
## filter, specifically with `ContentTopic`, and a `Message`. The `Message`
|
|
|
|
## has to match the `ContentTopic`.
|
|
|
|
|
|
|
|
## Status: Not yet implemented.
|
2020-08-27 10:15:46 +00:00
|
|
|
## TODO Implement as wrapper around `waku_filter` and `subscribe` above.
|
2020-07-27 09:01:06 +00:00
|
|
|
|
|
|
|
method unsubscribe*(w: WakuNode, topic: Topic)
|
|
|
|
## Unsubscribe from a topic.
|
|
|
|
##
|
|
|
|
## Status: Not yet implemented.
|
|
|
|
## TODO Implement.
|
|
|
|
|
|
|
|
method unsubscribe*(w: WakuNode, contentFilter: ContentFilter)
|
|
|
|
## Unsubscribe from a content filter.
|
|
|
|
##
|
|
|
|
## Status: Not yet implemented.
|
|
|
|
## TODO Implement.
|
|
|
|
|
2020-09-01 15:20:38 +00:00
|
|
|
method publish*(w: WakuNode, topic: Topic, message: WakuMessage)
|
|
|
|
## Publish a `WakuMessage` to a PubSub topic. `WakuMessage` should contain a
|
|
|
|
## `contentTopic` field for light node functionality. This field may be also
|
|
|
|
## be omitted.
|
2020-07-27 09:01:06 +00:00
|
|
|
##
|
2020-09-01 15:20:38 +00:00
|
|
|
## Status: Implemented.
|
2020-07-27 09:01:06 +00:00
|
|
|
|
|
|
|
method query*(w: WakuNode, query: HistoryQuery): HistoryResponse
|
|
|
|
## Queries for historical messages.
|
|
|
|
##
|
|
|
|
## Status: Not yet implemented.
|
2020-08-27 10:15:46 +00:00
|
|
|
## TODO Implement as wrapper around `waku_store` and send RPC.
|
2020-07-07 04:54:31 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## JSON RPC
|
|
|
|
|
2020-07-27 09:01:06 +00:00
|
|
|
### TODO To specify
|