Files
01.md
02.md
03.md
04.md
05.md
06.md
07.md
08.md
09.md
10.md
11.md
12.md
13.md
14.md
15.md
16.md
17.md
18.md
19.md
20.md
21.md
22.md
23.md
24.md
25.md
26.md
27.md
28.md
29.md
30.md
31.md
32.md
33.md
34.md
35.md
36.md
37.md
38.md
39.md
40.md
42.md
44.md
45.md
46.md
47.md
48.md
49.md
50.md
51.md
52.md
53.md
54.md
55.md
56.md
57.md
58.md
59.md
60.md
61.md
62.md
64.md
65.md
66.md
68.md
69.md
70.md
71.md
72.md
73.md
75.md
78.md
7D.md
84.md
86.md
88.md
89.md
90.md
92.md
94.md
96.md
98.md
99.md
BREAKING.md
C0.md
C7.md
README.md
nips/86.md
fiatjaf_ 73f65133fc add NIP-86: Relay Management API ()
Co-authored-by: Alex Gleason <alex@alexgleason.me>
2024-11-25 13:21:47 -03:00

3.2 KiB

NIP-86

Relay Management API

draft optional

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.

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:

{
  "method": "<method-name>",
  "params": ["<array>", "<of>", "<parameters>"]
}

Then it should return a response in the format

{
  "result": {"<arbitrary>": "<value>"},
  "error": "<optional error message, if the call has errored>"
}

This is the list of methods that may be supported:

  • supportedmethods:
    • params: []
    • result: ["<method-name>", "<method-name>", ...] (an array with the names of all the other supported methods)
  • banpubkey:
    • params: ["<32-byte-hex-public-key>", "<optional-reason>"]
    • result: true (a boolean always set to true)
  • listbannedpubkeys:
    • params: []
    • result: [{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...], an array of objects
  • allowpubkey:
    • params: ["<32-byte-hex-public-key>", "<optional-reason>"]
    • result: true (a boolean always set to true)
  • listallowedpubkeys:
    • params: []
    • result: [{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...], an array of objects
  • listeventsneedingmoderation:
    • params: []
    • result: [{"id": "<32-byte-hex>", "reason": "<optional-reason>"}], an array of objects
  • allowevent:
    • params: ["<32-byte-hex-event-id>", "<optional-reason>"]
    • result: true (a boolean always set to true)
  • banevent:
    • params: ["<32-byte-hex-event-id>", "<optional-reason>"]
    • result: true (a boolean always set to true)
  • listbannedevents:
    • params: []
    • result: [{"id": "<32-byte hex>", "reason": "<optional-reason>"}, ...], an array of objects
  • changerelayname:
    • params: ["<new-name>"]
    • result: true (a boolean always set to true)
  • changerelaydescription:
    • params: ["<new-description>"]
    • result: true (a boolean always set to true)
  • changerelayicon:
    • params: ["<new-icon-url>"]
    • result: true (a boolean always set to true)
  • allowkind:
    • params: [<kind-number>]
    • result: true (a boolean always set to true)
  • disallowkind:
    • params: [<kind-number>]
    • result: true (a boolean always set to true)
  • listallowedkinds:
    • params: []
    • result: [<kind-number>, ...], an array of numbers
  • blockip:
    • params: ["<ip-address>", "<optional-reason>"]
    • result: true (a boolean always set to true)
  • unblockip:
    • params: ["<ip-address>"]
    • result: true (a boolean always set to true)
  • listblockedips:
    • params: []
    • result: [{"ip": "<ip-address>", "reason": "<optional-reason>"}, ...], an array of objects

Authorization

The request must contain an Authorization header with a valid NIP-98 event, except the payload tag is required. The u tag is the relay URL.

If Authorization is not provided or is invalid, the endpoint should return a 401 response.