From 9ac33ce9e8f0454053c801e3ee142ea3bcb81695 Mon Sep 17 00:00:00 2001 From: LordGhostX Date: Tue, 21 Nov 2023 20:07:11 +0100 Subject: [PATCH] add REST API refs --- docs/guides/js-waku/run-waku-nodejs.md | 2 +- docs/guides/nodes-and-sdks.md | 2 +- docs/guides/nwaku/run-docker-compose.md | 17 +++++++++------- docs/guides/run-nwaku-node.md | 26 ++++++++----------------- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/docs/guides/js-waku/run-waku-nodejs.md b/docs/guides/js-waku/run-waku-nodejs.md index 9336309..95f8993 100644 --- a/docs/guides/js-waku/run-waku-nodejs.md +++ b/docs/guides/js-waku/run-waku-nodejs.md @@ -26,7 +26,7 @@ Certain features in `@waku/sdk` are tailored for browsers and might not translat ## Recommendations -Before using `@waku/sdk` in a NodeJS environment, take into account these limitations. For a more optimised solution, we recommend [running nwaku in a Docker container](/guides/nwaku/run-docker) and consuming its [JSON RPC API](https://rfc.vac.dev/spec/16/). +Before using `@waku/sdk` in a NodeJS environment, take into account these limitations. For a more optimised solution, we recommend [running nwaku in a Docker container](/guides/nwaku/run-docker) and consuming its [REST API](https://waku-org.github.io/waku-rest-api/). ## Future Developments diff --git a/docs/guides/nodes-and-sdks.md b/docs/guides/nodes-and-sdks.md index a99a762..a04e522 100644 --- a/docs/guides/nodes-and-sdks.md +++ b/docs/guides/nodes-and-sdks.md @@ -42,7 +42,7 @@ Waku provides integrations tailored for mobile applications, enabling Waku to ru | | Description | Documentation | | - | - | - | -| JSON-RPC API | `JSON-RPC` API interface provided by `nwaku` and `go-waku` to interact with the Waku Network | COMING SOON | +| [REST API](https://waku-org.github.io/waku-rest-api/) | REST API interface provided by `nwaku` and `go-waku` to interact with the Waku Network | [Waku Node REST API Spec](https://waku-org.github.io/waku-rest-api/) | | [@waku/react](https://www.npmjs.com/package/@waku/react) | React components and UI adapters designed for seamless integration with `@waku/sdk` | COMING SOON | | [@waku/create-app](https://www.npmjs.com/package/@waku/create-app) | Starter kit to bootstrap your next `@waku/sdk` project from various example templates | [Bootstrap DApps Using @waku/create-app](/guides/js-waku/use-waku-create-app) | | [nwaku-compose](https://github.com/waku-org/nwaku-compose) | Pre-configured Docker Compose setup for running and monitoring a `nwaku` node using Prometheus and Grafana | [Run Nwaku with Docker Compose](/guides/nwaku/run-docker-compose) | \ No newline at end of file diff --git a/docs/guides/nwaku/run-docker-compose.md b/docs/guides/nwaku/run-docker-compose.md index 9394706..e9afc92 100644 --- a/docs/guides/nwaku/run-docker-compose.md +++ b/docs/guides/nwaku/run-docker-compose.md @@ -71,25 +71,28 @@ Your `nwaku` node provides a [REST API](https://waku-org.github.io/waku-rest-api ```shell # Get nwaku version -curl http://127.0.0.1:8645/debug/v1/version +curl --location 'http://127.0.0.1:8645/debug/v1/version' # Get nwaku info -curl http://127.0.0.1:8645/debug/v1/info +curl --location 'http://127.0.0.1:8645/debug/v1/info' ``` Send a message to a `contentTopic`, which all subscribers will receive. Please note that the payload is encoded in `base64`. ```shell -curl -X POST "http://127.0.0.1:8645/relay/v1/auto/messages" \ - -H "content-type: application/json" \ - -d '{"payload":"'$(echo -n "Hello Waku Network - from Anonymous User" | base64)'","contentTopic":"/my-app/2/chatroom-1/proto"}' +curl --location 'http://127.0.0.1:8645/relay/v1/auto/messages' \ +--header 'Content-Type: application/json' \ +--data '{ + "payload": "'$(echo -n "Hello Waku Network - from Anonymous User" | base64)'", + "contentTopic": "/my-app/2/chatroom-1/proto" +}' ``` Retrieve messages sent to a `contentTopic`. Please note that this query can be made to any `Store` node within the network: ```shell -curl -X GET "http://127.0.0.1:8645/store/v1/messages?contentTopics=%2Fmy-app%2F2%2Fchatroom-1%2Fproto&pageSize=50&ascending=true" \ - -H "accept: application/json" +curl --location 'http://127.0.0.1:8645/store/v1/messages?contentTopics=%2Fmy-app%2F2%2Fchatroom-1%2Fproto&pageSize=50&ascending=true' \ +--header 'Accept: application/json' ``` :::tip Congratulations! diff --git a/docs/guides/run-nwaku-node.md b/docs/guides/run-nwaku-node.md index f601dcf..8edee17 100644 --- a/docs/guides/run-nwaku-node.md +++ b/docs/guides/run-nwaku-node.md @@ -69,7 +69,7 @@ You can configure a `nwaku` node to use multiple peer discovery mechanisms simul ## Interact with the Node -You can interact with a running `nwaku` node through the [JSON RPC API](https://rfc.vac.dev/spec/16/), such as querying the node information using the `get_waku_v2_debug_v1_info` method: +You can interact with a running `nwaku` node through the [REST API](https://waku-org.github.io/waku-rest-api/), such as querying the node information using the [Get node info](https://waku-org.github.io/waku-rest-api/#get-/debug/v1/info) endpoint: ```mdx-code-block import Tabs from '@theme/Tabs'; @@ -80,14 +80,8 @@ import TabItem from '@theme/TabItem'; ```bash -curl --location --request GET 'http://localhost:8545' \ ---header 'Content-Type: application/json' \ ---data '{ - "jsonrpc": "2.0", - "id": "id", - "method": "get_waku_v2_debug_v1_info", - "params": [] -}' +curl --location 'http://127.0.0.1:8645/debug/v1/info' \ +--header 'Accept: application/json' ``` @@ -95,14 +89,10 @@ curl --location --request GET 'http://localhost:8545' \ ```json { - "jsonrpc": "2.0", - "id": "id", - "result": { - "listenAddresses": [ - "/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmUbPquFQqje3jiqoB5YoiUbBya59NB4qqEzeiTNGHeA6w" - ], - "enrUri": "enr:-Iu4QCQZXZDb_JsYmLoYor0F5E_95HbIywgO_wgx2rIdDbmCJZkTzmlCr0wmMzV47lgik_tVwww5mIng90Ris83TisMBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQPszztG-Ev52ZB7tk0jF8s6Md4KvyY_rhzNZokaaB_ABIN0Y3CC6mCFd2FrdTIB" - } + "listenAddresses": [ + "/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmUbPquFQqje3jiqoB5YoiUbBya59NB4qqEzeiTNGHeA6w" + ], + "enrUri": "enr:-Iu4QCQZXZDb_JsYmLoYor0F5E_95HbIywgO_wgx2rIdDbmCJZkTzmlCr0wmMzV47lgik_tVwww5mIng90Ris83TisMBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQPszztG-Ev52ZB7tk0jF8s6Md4KvyY_rhzNZokaaB_ABIN0Y3CC6mCFd2FrdTIB" } ``` @@ -115,7 +105,7 @@ The `listenAddresses` field stores the node's listening addresses, while the `en ## Find the Node Addresses -You can find the addresses of a running node through its logs or by calling the `get_waku_v2_debug_v1_info` method of the [JSON RPC API](https://rfc.vac.dev/spec/16/). +You can find the addresses of a running node through its logs or by calling the [Get node info](https://waku-org.github.io/waku-rest-api/#get-/debug/v1/info) endpoint of the [REST API](https://waku-org.github.io/waku-rest-api/). :::info When starting the node, `nwaku` will display all the public listening and discovery addresses at the `INFO` log level.