nip200: idea for chunked stream by mattn

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle 2024-01-11 22:29:38 +07:00
parent 246539288d
commit f540cf8c49
2 changed files with 19 additions and 5 deletions

3
11.md
View File

@ -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"
},
...
}

21
200.md
View File

@ -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:
- `<count>?<filter>`, or
- `<req>?<filter>`
- `<count>?<filter>`,
- `<req>?<filter>`, or
- `<stream>?<filter>`
`<filter>` 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": .... }
```