From f540cf8c49748a85f598b1189d2c79596b3f799d Mon Sep 17 00:00:00 2001 From: Yonle Date: Thu, 11 Jan 2024 22:29:38 +0700 Subject: [PATCH] nip200: idea for chunked stream by mattn Signed-off-by: Yonle --- 11.md | 3 ++- 200.md | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/11.md b/11.md index d37be246..c474b91f 100644 --- a/11.md +++ b/11.md @@ -277,7 +277,8 @@ URL Paths to NoH endpoints. "req": "http://my-relay/__nostr/req", "count": "http://my-relay/__nostr/count", "publish": "http://my-relay/__nostr/pub", - "auth": "http://my-relay/__nostr/auth" + "auth": "http://my-relay/__nostr/auth", + "stream": "http://my-relay/__nostr/stream" }, ... } diff --git a/200.md b/200.md index 677766f1..6ea40e1b 100644 --- a/200.md +++ b/200.md @@ -14,13 +14,14 @@ Relays may expose NoH endpoints that client could reach. Client may make HTTP re Relays must ensure that the NoH endpoints **MUST** be served with `Access-Control-Allow-Origin: *` header to ensure it can be validated by pure JS apps running in modern browsers. -### From client to relay: getting events and sending event +### From client to relay: fetching and sending event(s) -Client could make a request to `req`, `count` or `publish` endpoint that were specified in `/.well-known/nostr.json` +Client could make a request to `req`, `count`, `publish`, or `stream` endpoint that were specified in `/.well-known/nostr.json` When fetching events, Client can optionally specify filters directly into the URI search query: -- `?`, or -- `?` +- `?`, +- `?`, or +- `?` `` is a querystrings that determines what events will be received in that request. it can have the following attributes: @@ -38,6 +39,7 @@ Request URL Examples: - `https://my-relay.com/__nostr/req?kinds=0,1&limit=10` - `https://my-relay.com/__nostr/req?authors=12345,67890` - `https://my-relay.com/__nostr/count?count=100&authors=12345,kinds=0` +- `https://my-relay.com/__nostr/stream?since=12345&kinds=0,1&limit=10` To send event to relay, Client will need to make POST request to `publish` endpoint with POST body containing the JSON blob of the event. @@ -54,3 +56,14 @@ At certain condition, Relay will also respond with HTTP status code: - `200`: OK / Success - `400`: Invalid Request - `500`: Relay/Server error + +### From relay to client: streaming events to client + +Relay may start streaming to client when connected to `stream` endpoint by sending chunked JSON blob of events until reached to `limit` that being set by client. + +``` +{ "id": ..., "content": .... } +{ "id": ..., "content": .... } +{ "id": ..., "content": .... } +{ "id": ..., "content": .... } +```