mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-02-24 06:09:01 +00:00
185 lines
4.7 KiB
Markdown
185 lines
4.7 KiB
Markdown
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:
|
|
|
|
```json
|
|
{
|
|
"method": "<method-name>",
|
|
"params": ["<array>", "<of>", "<parameters>"]
|
|
}
|
|
```
|
|
|
|
Then it should return a response in the below format:
|
|
|
|
```json
|
|
{
|
|
"result": {"<arbitrary>": "<value>"},
|
|
"error": "<optional error message, if the call has errored>"
|
|
}
|
|
```
|
|
|
|
## Standard Methods
|
|
|
|
Here is a list of **methods** that MAY be supported:
|
|
|
|
* `supportedmethods`:
|
|
- **params:** `[]`
|
|
- **result:** `["<method-name>", "<method-name>", /* rest of method names... */ ]`
|
|
|
|
Extra fields MAY be sent from the relay depending on implementation.
|
|
|
|
---
|
|
|
|
* `stats`:
|
|
- **params:** `[]`
|
|
- **result:**
|
|
```jsonc
|
|
[
|
|
{
|
|
"num_connections": <number>,
|
|
"uptime": <uptime-in-seconds>,
|
|
"bytes_received": <number>,
|
|
"bytes_sent": <number>,
|
|
"num_events": <number>,
|
|
"event_bytes": <number>,
|
|
"num_files": <number>,
|
|
"file_bytes": <number>
|
|
// and more...
|
|
}
|
|
]
|
|
```
|
|
|
|
Extra fields MAY be sent from the relay depending on implementation.
|
|
|
|
---
|
|
|
|
* `listeventsneedingmoderation`:
|
|
- **params:** `[]`
|
|
- **result:** `[{ "id": "<32-byte-hex>", "reason": "<optional-reason>" }, ...]` (Relay MAY return reported, muted profiles and similar events as a result.)
|
|
|
|
---
|
|
|
|
* `banpubkey`:
|
|
- **params:** `["<32-byte-hex-public-key>", "<optional-reason>"]`
|
|
- **result:** `true` (a boolean always set to `true`)
|
|
|
|
The relay MAY remove events sent by `pubkey` and prevent new events from being written.
|
|
|
|
---
|
|
|
|
* `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)
|
|
|
|
---
|
|
|
|
* `banevent`:
|
|
- **params:** `["<32-byte-hex-event-id>", "<optional-reason>"]`
|
|
- **result:** `true` (a boolean always set to `true`)
|
|
|
|
Relay SHOULD delete and prevent re-broadcasting of event.
|
|
|
|
---
|
|
|
|
* `listbannedevents`:
|
|
- **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`)
|
|
|
|
---
|
|
|
|
* `listallowedevents`:
|
|
- **params:** `[]`
|
|
- **result:** `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
|
|
|
|
---
|
|
|
|
* `allowkinds`:
|
|
- **params:** `(<kind-number>, <another-kind-number>, /* and more... */)`
|
|
- **result:** `true` (a boolean always set to `true`)
|
|
|
|
---
|
|
|
|
* `disallowkinds`:
|
|
- **params:** `(<kind-number>, <another-kind-number>, /* and more... */)`
|
|
- **result:** `true` (a boolean always set to `true`)
|
|
|
|
---
|
|
|
|
* `listdisallowedkinds`:
|
|
- **params:** `[]`
|
|
- **result:** `(<kind-number>, <another-kind-number>, /* and more... */)` (an array of objects)
|
|
|
|
---
|
|
|
|
* `listallowedkinds`:
|
|
- **params:** `[]`
|
|
- **result:** `(<kind-number>, <another-kind-number>, /* and more... */)` (an array of objects)
|
|
|
|
---
|
|
|
|
* `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)
|
|
|
|
---
|
|
|
|
* `grantadmin`:
|
|
- **params:** `["<32-byte-hex-public-key>", { "allowed_methods": [...]}]`
|
|
- **result:** `true` (a boolean always set to `true`)
|
|
|
|
If the admin right is already granted, the allowed methods list must be rewritten.
|
|
|
|
---
|
|
|
|
* `revokeadmin`:
|
|
- **params:** `["<32-byte-hex-public-key>", { "disallowed_methods": [...]}]`
|
|
- **result:** `true` (a boolean always set to `true`)
|
|
|
|
If the resulting `allowed_methods` list for admin was empty, admin can be removed.
|
|
|
|
---
|
|
|
|
### Authorization
|
|
|
|
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.
|
|
|
|
If `Authorization` is not provided or is invalid, the endpoint should return a response with a 401 status code.
|