Paso 1 de 5
La misma dirección, HTTP normal
La API de gestión vive en la propia URL del relay, accesible por https en lugar de wss. El relay la reconoce por el Content-Type application/nostr+json+rpc.
NIP-86
BorradorHTTP
Una API HTTP, en la misma dirección que el WebSocket del relay, que permite a su operador vetar pubkeys, permitir kinds y moderar eventos con llamadas JSON-RPC sencillas firmadas mediante NIP-98.
Edita el formulario o el JSON: ambos se mantienen sincronizados, la insignia indica si el resultado es válido y, al tocar cualquier campo, se explica qué hace.
Cómo se conectan las partes: Firma y luego llama
Selecciona cualquier campo del formulario o del JSON para ver qué hace.
Paso 1 de 5
La API de gestión vive en la propia URL del relay, accesible por https en lugar de wss. El relay la reconoce por el Content-Type application/nostr+json+rpc.
Ningún capítulo del curso cubre este NIP todavía. El editor de arriba es la forma más rápida de empezar.
Cada llamada se autoriza con un evento NIP-98 en la cabecera Authorization.
El documento de información del relay se sirve desde la misma URL con otra cabecera Accept.
Los métodos claim gestionan los códigos de invitación de NIP-43.
NIP-42 autentica a los clientes WebSocket; esta API usa en cambio autenticación HTTP.
El texto de las especificaciones se cita en inglés del repositorio nostr-protocol/nips. Nuestras explicaciones y la interfaz están traducidas. Código fuente en GitHub en el commit 0046368
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:
supportedmethodsLists the methods supported by the relay. May be customized to match permissions assigned to the authenticated user.
[]["<method-name>", "<method-name>", ...] (an array with the names of all the other supported methods)banpubkeyBans a pubkey from the relay. Should automatically remove the pubkey from the allow list.
["<32-byte-hex-public-key>", "<optional-reason>"]true (a boolean always set to true)unbanpubkeyRemoves a pubkey from the relay's ban list. Should not automatically add the pubkey to the allow list.
["<32-byte-hex-public-key>", "<optional-reason>"]true (a boolean always set to true)listbannedpubkeysLists pubkeys banned from the relay.
[][{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...], an array of objectsallowpubkeyAdds a pubkey to the relay's allow list. Should automatically remove the pubkey from the ban list.
["<32-byte-hex-public-key>", "<optional-reason>"]true (a boolean always set to true)unallowpubkeyRemoves a pubkey from the relay's allow list. Should not automatically add the pubkey to the ban list.
["<32-byte-hex-public-key>", "<optional-reason>"]true (a boolean always set to true)listallowedpubkeysLists pubkeys on the relay's allow list.
[][{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...], an array of objectscreateroleCreates a new role.
[id, label, description, color, order]true (boolean true)editroleUpdates an existing role.
[id, label, description, color, order]true (boolean true)deleteroleDeletes a role.
[id]true (boolean true)assignroleAssigns a role to a pubkey.
["<32-byte-hex-public-key>", "<role-id>"]true (a boolean always set to true)unassignroleRemoves a role from a pubkey.
["<32-byte-hex-public-key>", "<role-id>"]true (a boolean always set to true)listclaimsLists NIP 43 invite codes currently accepted by the relay.
[][claim, ...], an array of NIP 43 invite codescreateclaimCreates a new NIP 43 invite code.
[claim]true (boolean true)deleteclaimRevokes a NIP 43 invite code.
[claim]true (boolean true)listeventsneedingmoderationLists events awaiting moderation.
[][{"id": "<32-byte-hex>", "reason": "<optional-reason>"}], an array of objectsalloweventAdds an event to the relay's allow list. Should automatically remove the event from the ban list.
["<32-byte-hex-event-id>", "<optional-reason>"]true (a boolean always set to true)unalloweventRemoves an event from the relay's allow list. Should not automatically add the event to the ban list.
["<32-byte-hex-event-id>", "<optional-reason>"]true (a boolean always set to true)baneventBans an event from the relay. Should automatically remove the event from the allow list.
["<32-byte-hex-event-id>", "<optional-reason>"]true (a boolean always set to true)unbaneventRemoves an event from the relay's ban list. Should not automatically add the event to the allow list.
["<32-byte-hex-event-id>", "<optional-reason>"]true (a boolean always set to true)listbannedeventsLists events banned from the relay.
[][{"id": "<32-byte hex>", "reason": "<optional-reason>"}, ...], an array of objectslistallowedeventsLists events on the relay's allow list.
[][{"id": "<32-byte-hex>", "reason": "<optional-reason>"}, ...], an array of objectschangerelaynameChanges the relay's name.
["<new-name>"]true (a boolean always set to true)changerelaydescriptionChanges the relay's description.
["<new-description>"]true (a boolean always set to true)changerelayiconChanges the relay's icon.
["<new-icon-url>"]true (a boolean always set to true)allowkindAdds an event kind to the relay's allow list.
[<kind-number>]true (a boolean always set to true)disallowkindDisallows an event kind.
[<kind-number>]true (a boolean always set to true)listallowedkindsLists event kinds on the relay's allow list.
[][<kind-number>, ...], an array of numberslistdisallowedkindsLists event kinds the relay disallows.
[][<kind-number>, ...], an array of numbersblockipAdds an IP address to the relay's block list.
["<ip-address>", "<optional-reason>"]true (a boolean always set to true)unblockipRemoves an IP address from the relay's block list.
["<ip-address>"]true (a boolean always set to true)listblockedipsLists IP addresses blocked by the relay.
[][{"ip": "<ip-address>", "reason": "<optional-reason>"}, ...], an array of objectsThe 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.