3.3 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 an Authorization
header and 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)
- params:
banpubkey
:- params:
["<32-byte-hex-public-key>", "<optional-reason>"]
- result:
true
(a boolean always set totrue
)
- params:
listbannedpubkeys
:- params:
[]
- result:
[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]
, an array of objects
- params:
allowpubkey
:- params:
["<32-byte-hex-public-key>", "<optional-reason>"]
- result:
true
(a boolean always set totrue
)
- params:
listallowedpubkeys
:- params:
[]
- result:
[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]
, an array of objects
- params:
listeventsneedingmoderation
:- params:
[]
- result:
[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}]
, an array of objects
- params:
allowevent
:- params:
["<32-byte-hex-event-id>", "<optional-reason>"]
- result:
true
(a boolean always set totrue
)
- params:
banevent
:- params:
["<32-byte-hex-event-id>", "<optional-reason>"]
- result:
true
(a boolean always set totrue
)
- params:
listbannedevents
:- params:
[]
- result:
[{"id": "<32-byte hex>", "reason": "<optional-reason>"}, ...]
, an array of objects
- params:
changerelayname
:- params:
["<new-name>"]
- result:
true
(a boolean always set totrue
)
- params:
changerelaydescription
:- params:
["<new-description>"]
- result:
true
(a boolean always set totrue
)
- params:
changerelayicon
:- params:
["<new-icon-url>"]
- result:
true
(a boolean always set totrue
)
- params:
allowkind
:- params:
[<kind-number>]
- result:
true
(a boolean always set totrue
)
- params:
disallowkind
:- params:
[<kind-number>]
- result:
true
(a boolean always set totrue
)
- params:
listallowedkinds
:- params:
[]
- result:
[<kind-number>, ...]
, an array of numbers
- params:
blockip
:- params:
["<ip-address>", "<optional-reason>"]
- result:
true
(a boolean always set totrue
)
- params:
unblockip
:- params:
["<ip-address>"]
- result:
true
(a boolean always set totrue
)
- params:
listblockedips
:- params:
[]
- result:
[{"ip": "<ip-address>", "reason": "<optional-reason>"}, ...]
, an array of objects
- params:
Authorization
The request must contain an Authorization
header with the value set to Nostr <base64(auth-event)>
in which <auth-event>
is an event of kind 27235
with a tag ["host", <hostname-of-target-relay>]
, a tag ["payload", <sha256-hash-of-the-request-body-as-lowercase-hex>]
and created_at
set to the current timestamp.