2022-05-01 10:48:57 +00:00
NIP-11
======
Relay Information Document
---------------------------
2023-11-16 00:42:51 +00:00
`draft` `optional`
2022-05-01 10:48:57 +00:00
Relays may provide server metadata to clients to inform them of capabilities, administrative contacts, and various server attributes. This is made available as a JSON document over HTTP, on the same URI as the relay's websocket.
When a relay receives an HTTP(s) request with an `Accept` header of `application/nostr+json` to a URI supporting WebSocket upgrades, they SHOULD return a document with the following structure.
```json
{
2023-01-13 20:59:19 +00:00
"name": < string identifying relay > ,
"description": < string with detailed information > ,
"pubkey": < administrative contact pubkey > ,
"contact": < administrative alternate contact > ,
"supported_nips": < a list of NIP numbers supported by the relay > ,
"software": < string identifying relay software URL > ,
"version": < string version identifier >
2022-05-01 10:48:57 +00:00
}
```
2022-11-23 20:46:25 +00:00
Any field may be omitted, and clients MUST ignore any additional fields they do not understand. Relays MUST accept CORS requests by sending `Access-Control-Allow-Origin` , `Access-Control-Allow-Headers` , and `Access-Control-Allow-Methods` headers.
2022-05-01 10:48:57 +00:00
Field Descriptions
2023-11-18 11:21:15 +00:00
------------------
2022-05-01 10:48:57 +00:00
2023-11-18 11:21:15 +00:00
### Name
2022-05-01 10:48:57 +00:00
A relay may select a `name` for use in client software. This is a string, and SHOULD be less than 30 characters to avoid client truncation.
2023-11-18 11:21:15 +00:00
### Description
2022-05-01 10:48:57 +00:00
Detailed plain-text information about the relay may be contained in the `description` string. It is recommended that this contain no markup, formatting or line breaks for word wrapping, and simply use double newline characters to separate paragraphs. There are no limitations on length.
2023-11-18 11:21:15 +00:00
### Pubkey
2022-05-01 10:48:57 +00:00
An administrative contact may be listed with a `pubkey` , in the same format as Nostr events (32-byte hex for a `secp256k1` public key). If a contact is listed, this provides clients with a recommended address to send encrypted direct messages (See `NIP-04` ) to a system administrator. Expected uses of this address are to report abuse or illegal content, file bug reports, or request other technical assistance.
Relay operators have no obligation to respond to direct messages.
2023-11-18 11:21:15 +00:00
### Contact
2022-05-01 10:48:57 +00:00
An alternative contact may be listed under the `contact` field as well, with the same purpose as `pubkey` . Use of a Nostr public key and direct message SHOULD be preferred over this. Contents of this field SHOULD be a URI, using schemes such as `mailto` or `https` to provide users with a means of contact.
2023-11-18 11:21:15 +00:00
### Supported NIPs
2022-05-01 10:48:57 +00:00
2022-12-16 14:17:38 +00:00
As the Nostr protocol evolves, some functionality may only be available by relays that implement a specific `NIP` . This field is an array of the integer identifiers of `NIP` s that are implemented in the relay. Examples would include `1` , for `"NIP-01"` and `9` , for `"NIP-09"` . Client-side `NIPs` SHOULD NOT be advertised, and can be ignored by clients.
2022-05-01 10:48:57 +00:00
2023-11-18 11:21:15 +00:00
### Software
2022-05-01 10:48:57 +00:00
The relay server implementation MAY be provided in the `software` attribute. If present, this MUST be a URL to the project's homepage.
2023-11-18 11:21:15 +00:00
### Version
2022-05-01 10:48:57 +00:00
The relay MAY choose to publish its software version as a string attribute. The string format is defined by the relay implementation. It is recommended this be a version number or commit identifier.
2023-03-18 22:44:31 +00:00
Extra Fields
2023-11-18 11:21:15 +00:00
------------
2023-03-18 22:44:31 +00:00
2023-11-18 11:21:15 +00:00
### Server Limitations
2023-03-18 22:44:31 +00:00
These are limitations imposed by the relay on clients. Your client
should expect that requests which exceed these *practical* limitations
are rejected or fail immediately.
```json
{
2023-05-09 13:09:45 +00:00
"limitation": {
2023-11-18 11:21:15 +00:00
"max_message_length": 16384,
"max_subscriptions": 20,
"max_filters": 100,
"max_limit": 5000,
"max_subid_length": 100,
"max_event_tags": 100,
"max_content_length": 8196,
"min_pow_difficulty": 30,
"auth_required": true,
"payment_required": true,
2023-11-18 12:36:59 +00:00
"restricted_writes": true,
2023-11-18 11:21:15 +00:00
"created_at_lower_limit": 31536000,
"created_at_upper_limit": 3
2023-11-18 12:13:12 +00:00
},
...
2023-03-18 22:44:31 +00:00
}
```
- `max_message_length` : this is the maximum number of bytes for incoming JSON that the relay
will attempt to decode and act upon. When you send large subscriptions, you will be
limited by this value. It also effectively limits the maximum size of any event. Value is
calculated from `[` to `]` and is after UTF-8 serialization (so some unicode characters
will cost 2-3 bytes). It is equal to the maximum size of the WebSocket message frame.
- `max_subscriptions` : total number of subscriptions that may be
active on a single websocket connection to this relay. It's possible
that authenticated clients with a (paid) relationship to the relay
may have higher limits.
- `max_filters` : maximum number of filter values in each subscription.
Must be one or higher.
- `max_subid_length` : maximum length of subscription id as a string.
- `max_limit` : the relay server will clamp each filter's `limit` value to this number.
This means the client won't be able to get more than this number
of events from a single subscription filter. This clamping is typically done silently
by the relay, but with this number, you can know that there are additional results
if you narrowed your filter's time range or other parameters.
- `max_event_tags` : in any event, this is the maximum number of elements in the `tags` list.
- `max_content_length` : maximum number of characters in the `content`
field of any event. This is a count of unicode characters. After
serializing into JSON it may be larger (in bytes), and is still
subject to the `max_message_length` , if defined.
2023-08-13 16:47:45 +00:00
- `min_pow_difficulty` : new events will require at least this difficulty of PoW,
2023-03-18 22:44:31 +00:00
based on [NIP-13 ](13.md ), or they will be rejected by this server.
- `auth_required` : this relay requires [NIP-42 ](42.md ) authentication
to happen before a new connection may perform any other action.
Even if set to False, authentication may be required for specific actions.
- `payment_required` : this relay requires payment before a new connection may perform any action.
2023-11-18 12:36:59 +00:00
- `restricted_writes` : this relay requires some kind of condition to be fulfilled in order to
accept events (not necessarily, but including `payment_required` and `min_pow_difficulty` ).
2023-08-30 23:30:41 +00:00
- `created_at_lower_limit` : 'created_at' lower limit as defined in [NIP-22 ](22.md )
- `created_at_upper_limit` : 'created_at' upper limit as defined in [NIP-22 ](22.md )
2023-11-18 11:21:15 +00:00
### Event Retention
2023-03-18 22:44:31 +00:00
2023-08-13 16:47:45 +00:00
There may be a cost associated with storing data forever, so relays
2023-03-18 22:44:31 +00:00
may wish to state retention times. The values stated here are defaults
for unauthenticated users and visitors. Paid users would likely have
other policies.
Retention times are given in seconds, with `null` indicating infinity.
If zero is provided, this means the event will not be stored at
all, and preferably an error will be provided when those are received.
```json
{
2023-05-09 13:09:45 +00:00
"retention": [
2023-11-18 11:21:15 +00:00
{"kinds": [0, 1, [5, 7], [40, 49]], "time": 3600},
{"kinds": [[40000, 49999]], "time": 100},
{"kinds": [[30000, 39999]], "count": 1000},
{"time": 3600, "count": 10000}
2023-03-18 22:44:31 +00:00
]
}
```
2023-08-13 16:47:45 +00:00
`retention` is a list of specifications: each will apply to either all kinds, or
2023-03-18 22:44:31 +00:00
a subset of kinds. Ranges may be specified for the kind field as a tuple of inclusive
start and end values. Events of indicated kind (or all) are then limited to a `count`
2023-05-09 13:09:45 +00:00
and/or time period.
2023-03-18 22:44:31 +00:00
It is possible to effectively blacklist Nostr-based protocols that rely on
a specific `kind` number, by giving a retention time of zero for those `kind` values.
While that is unfortunate, it does allow clients to discover servers that will
support their protocol quickly via a single HTTP fetch.
2023-08-13 16:47:45 +00:00
There is no need to specify retention times for _ephemeral events_ since they are not retained.
2023-03-18 22:44:31 +00:00
2023-11-18 11:21:15 +00:00
### Content Limitations
2023-03-18 22:44:31 +00:00
Some relays may be governed by the arbitrary laws of a nation state. This
may limit what content can be stored in cleartext on those relays. All
clients are encouraged to use encryption to work around this limitation.
It is not possible to describe the limitations of each country's laws
and policies which themselves are typically vague and constantly shifting.
Therefore, this field allows the relay operator to indicate which
2023-05-09 13:09:45 +00:00
countries' laws might end up being enforced on them, and then
indirectly on their users' content.
2023-03-18 22:44:31 +00:00
Users should be able to avoid relays in countries they don't like,
and/or select relays in more favourable zones. Exposing this
flexibility is up to the client software.
```json
{
2023-11-18 12:13:12 +00:00
"relay_countries": [ "CA", "US" ],
2023-11-18 11:21:15 +00:00
...
2023-03-18 22:44:31 +00:00
}
```
- `relay_countries` : a list of two-level ISO country codes (ISO 3166-1 alpha-2) whose
laws and policies may affect this relay. `EU` may be used for European Union countries.
Remember that a relay may be hosted in a country which is not the
country of the legal entities who own the relay, so it's very
likely a number of countries are involved.
2023-11-18 11:21:15 +00:00
### Community Preferences
2023-03-18 22:44:31 +00:00
For public text notes at least, a relay may try to foster a
local community. This would encourage users to follow the global
feed on that relay, in addition to their usual individual follows.
To support this goal, relays MAY specify some of the following values.
```json
{
2023-11-18 12:13:12 +00:00
"language_tags": ["en", "en-419"],
"tags": ["sfw-only", "bitcoin-only", "anime"],
"posting_policy": "https://example.com/posting-policy.html",
2023-11-18 11:21:15 +00:00
...
2023-03-18 22:44:31 +00:00
}
```
- `language_tags` is an ordered list
of [IETF language tags ](https://en.wikipedia.org/wiki/IETF_language_tag ) indicating
the major languages spoken on the relay.
- `tags` is a list of limitations on the topics to be discussed.
2023-05-09 13:09:45 +00:00
For example `sfw-only` indicates that only "Safe For Work" content
2023-03-18 22:44:31 +00:00
is encouraged on this relay. This relies on assumptions of what the
"work" "community" feels "safe" talking about. In time, a common
set of tags may emerge that allow users to find relays that suit
their needs, and client software will be able to parse these tags easily.
The `bitcoin-only` tag indicates that any *altcoin* , *"crypto"* or *blockchain*
comments will be ridiculed without mercy.
- `posting_policy` is a link to a human-readable page which specifies the
community policies for the relay. In cases where `sfw-only` is True, it's
important to link to a page which gets into the specifics of your posting policy.
The `description` field should be used to describe your community
goals and values, in brief. The `posting_policy` is for additional
detail and legal terms. Use the `tags` field to signify limitations
on content, or topics to be discussed, which could be machine
processed by appropriate client software.
2023-11-18 11:21:15 +00:00
### Pay-to-Relay
2023-03-18 22:44:31 +00:00
Relays that require payments may want to expose their fee schedules.
```json
{
2023-05-09 13:09:45 +00:00
"payments_url": "https://my-relay/payments",
"fees": {
"admission": [{ "amount": 1000000, "unit": "msats" }],
"subscription": [{ "amount": 5000000, "unit": "msats", "period": 2592000 }],
"publication": [{ "kinds": [4], "amount": 100, "unit": "msats" }],
2023-11-18 12:13:12 +00:00
},
...
2023-03-18 22:44:31 +00:00
}
2023-04-08 02:13:18 +00:00
```
2023-05-02 14:41:59 +00:00
2023-11-18 11:21:15 +00:00
### Icon
2023-06-08 16:48:03 +00:00
2023-06-17 21:01:03 +00:00
A URL pointing to an image to be used as an icon for the relay. Recommended to be squared in shape.
2023-06-08 16:48:03 +00:00
```json
{
2023-06-17 21:01:03 +00:00
"icon": "https://nostr.build/i/53866b44135a27d624e99c6165cabd76ac8f72797209700acb189fce75021f47.jpg",
2023-11-18 12:13:12 +00:00
...
2023-06-08 16:48:03 +00:00
}
```
2023-11-18 11:21:15 +00:00
### Examples
As of 2 May 2023 the following command provided these results:
```
~> curl -H "Accept: application/nostr+json" https://eden.nostr.land | jq
{
"description": "nostr.land family of relays (us-or-01)",
"name": "nostr.land",
"pubkey": "52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd",
"software": "custom",
"supported_nips": [
1,
2,
4,
9,
11,
12,
16,
20,
22,
28,
33,
40
],
"version": "1.0.1",
"limitation": {
"payment_required": true,
"max_message_length": 65535,
"max_event_tags": 2000,
"max_subscriptions": 20,
"auth_required": false
},
"payments_url": "https://eden.nostr.land",
"fees": {
"subscription": [
{
"amount": 2500000,
"unit": "msats",
"period": 2592000
}
]
},
}