diff options
| author | fiatjaf_ <fiatjaf@gmail.com> | 2024-11-25 13:21:47 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-25 13:21:47 -0300 |
| commit | 73f65133fcdcbf9f4d27cc7097963797c6250cd7 (patch) | |
| tree | 71f2d1a3234e17071f96eadea015d28ce62d1f3b /86.md | |
| parent | e145577b0b1f54c45b4485cd841fbb4655d589c9 (diff) | |
add NIP-86: Relay Management API (#1325)
Co-authored-by: Alex Gleason <alex@alexgleason.me>
Diffstat (limited to '86.md')
| -rw-r--r-- | 86.md | 90 |
1 files changed, 90 insertions, 0 deletions
| @@ -0,0 +1,90 @@ | |||
| 1 | NIP-86 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Relay Management API | ||
| 5 | -------------------- | ||
| 6 | |||
| 7 | `draft` `optional` | ||
| 8 | |||
| 9 | Relays may provide an API for performing management tasks. This is made available as a JSON-RPC-like request-response protocol over HTTP, on the same URI as the relay's websocket. | ||
| 10 | |||
| 11 | When a relay receives an HTTP(s) request with a `Content-Type` header of `application/nostr+json+rpc` to a URI supporting WebSocket upgrades, it should parse the request as a JSON document with the following fields: | ||
| 12 | |||
| 13 | ```json | ||
| 14 | { | ||
| 15 | "method": "<method-name>", | ||
| 16 | "params": ["<array>", "<of>", "<parameters>"] | ||
| 17 | } | ||
| 18 | ``` | ||
| 19 | |||
| 20 | Then it should return a response in the format | ||
| 21 | |||
| 22 | ```json | ||
| 23 | { | ||
| 24 | "result": {"<arbitrary>": "<value>"}, | ||
| 25 | "error": "<optional error message, if the call has errored>" | ||
| 26 | } | ||
| 27 | ``` | ||
| 28 | |||
| 29 | This is the list of **methods** that may be supported: | ||
| 30 | |||
| 31 | * `supportedmethods`: | ||
| 32 | - params: `[]` | ||
| 33 | - result: `["<method-name>", "<method-name>", ...]` (an array with the names of all the other supported methods) | ||
| 34 | * `banpubkey`: | ||
| 35 | - params: `["<32-byte-hex-public-key>", "<optional-reason>"]` | ||
| 36 | - result: `true` (a boolean always set to `true`) | ||
| 37 | * `listbannedpubkeys`: | ||
| 38 | - params: `[]` | ||
| 39 | - result: `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]`, an array of objects | ||
| 40 | * `allowpubkey`: | ||
| 41 | - params: `["<32-byte-hex-public-key>", "<optional-reason>"]` | ||
| 42 | - result: `true` (a boolean always set to `true`) | ||
| 43 | * `listallowedpubkeys`: | ||
| 44 | - params: `[]` | ||
| 45 | - result: `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]`, an array of objects | ||
| 46 | * `listeventsneedingmoderation`: | ||
| 47 | - params: `[]` | ||
| 48 | - result: `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}]`, an array of objects | ||
| 49 | * `allowevent`: | ||
| 50 | - params: `["<32-byte-hex-event-id>", "<optional-reason>"]` | ||
| 51 | - result: `true` (a boolean always set to `true`) | ||
| 52 | * `banevent`: | ||
| 53 | - params: `["<32-byte-hex-event-id>", "<optional-reason>"]` | ||
| 54 | - result: `true` (a boolean always set to `true`) | ||
| 55 | * `listbannedevents`: | ||
| 56 | - params: `[]` | ||
| 57 | - result: `[{"id": "<32-byte hex>", "reason": "<optional-reason>"}, ...]`, an array of objects | ||
| 58 | * `changerelayname`: | ||
| 59 | - params: `["<new-name>"]` | ||
| 60 | - result: `true` (a boolean always set to `true`) | ||
| 61 | * `changerelaydescription`: | ||
| 62 | - params: `["<new-description>"]` | ||
| 63 | - result: `true` (a boolean always set to `true`) | ||
| 64 | * `changerelayicon`: | ||
| 65 | - params: `["<new-icon-url>"]` | ||
| 66 | - result: `true` (a boolean always set to `true`) | ||
| 67 | * `allowkind`: | ||
| 68 | - params: `[<kind-number>]` | ||
| 69 | - result: `true` (a boolean always set to `true`) | ||
| 70 | * `disallowkind`: | ||
| 71 | - params: `[<kind-number>]` | ||
| 72 | - result: `true` (a boolean always set to `true`) | ||
| 73 | * `listallowedkinds`: | ||
| 74 | - params: `[]` | ||
| 75 | - result: `[<kind-number>, ...]`, an array of numbers | ||
| 76 | * `blockip`: | ||
| 77 | - params: `["<ip-address>", "<optional-reason>"]` | ||
| 78 | - result: `true` (a boolean always set to `true`) | ||
| 79 | * `unblockip`: | ||
| 80 | - params: `["<ip-address>"]` | ||
| 81 | - result: `true` (a boolean always set to `true`) | ||
| 82 | * `listblockedips`: | ||
| 83 | - params: `[]` | ||
| 84 | - result: `[{"ip": "<ip-address>", "reason": "<optional-reason>"}, ...]`, an array of objects | ||
| 85 | |||
| 86 | ### Authorization | ||
| 87 | |||
| 88 | The request must contain an `Authorization` header with a valid [NIP-98](./98.md) event, except the `payload` tag is required. The `u` tag is the relay URL. | ||
| 89 | |||
| 90 | If `Authorization` is not provided or is invalid, the endpoint should return a 401 response. | ||