nostr is a network composed of dumb relays that exhibit different behaviors that are mostly, but not entirely self-reported by their NIP-11 document. However, discoverabililty of relays, and acquiring metadata for relays at the protocol level is not presently implemented. Additionally, self-reported data has an extremely low cieling and is not always reliable.
Starting in `NIP-66@draft6`**Relay Metadata** and **Relay Discoverability** are considered as two different cases and are split into two different events. However, there remains a pattern for monitors to flag that their `30066` events are indexable.
`10166` is a replacable event herein referred to as "Relay Monitor Registration" events. These events contain information about a publisher's intent to monitor and publish data as `NIP-66` events.
`NIP-66` kinds can be used by both "Relay Operators" and "Relay Monitors," with the exception that "Relay Operators" **SHOULD NOT** use `10166`
| Kind | Monitors | Operators |
|-------|----------|-----------|
| `10166` | x | |
| `30066` | x | x |
| `30166` | x | x |
### Schema
#### Summary
#### Non-Indexed Tags
-`url` A URL with human readable information about the monitor's activities. If not included, it is assumed these details are included in the monitor's `website` member in their `kind: 0` JSON for the pubkey that signed the `10066` event.
-`timeout` The timeout values for various tests. Index `1` is the monitor's timeout in milliseconds. Index `2` describes what test the timeout is used for, for example `open`, `read`, `write`, `info`, etc. If no index `2` is provided, it is inferred that the timeout provided applies to all tests.
-`frequency` The frequency at which the monitor publishes events. A string-integer at index `1` represents the frequency **in seconds** of the checks. There should only be `1` frequency per monitor.
-`k` "Kinds" **should** be a the string-representation of an integer that describes the NIP-66 kinds this monitor publishes. _Note: Kind `10166` **does not** need to be listed here._
While `30066` and `30166` have a high-level separation of concerns by Metadata and Discoverability, a monitor can decide to flag `30066` as indexable, and include indexed tags defined in `30166` within their `30066` Relay Metadata events.
-`c` "Checks" **should** be a lowercase string describing the check(s) conducted by a monitor. Some examples are: `rtt`, `nip11`, `ssl`, `dns`, `geo` and `count`. Other checks can be added via consensus.
-`n` "Counts" **should** be a lower-snake-case string describing the counts(s) conducted by a monitor at index `1`. Some examples are: `total_active_users`, `total_note_zaps`, `total_note_reactions`, `events_per_minute`, `note_publish_rate`. Counts are not atomized, their values are entirely ad-hoc. The time period of the count is defined in `30066`
-`g`: `NIP-66` leverages a draft NIP for geo tags, which is backwards compatible with `0` collisions for legacy `g` tags from `NIP-52`. See [YAGT](https://github.com/nostr-protocol/nips/pull/952)
`30166` is a `NIP-33` Parameterized-Replaceable Event [PRE], referred to as a "Relay Discoverability" event. These events are optimized with a small footprint for protocol-level relay discoverability, and contain no unindexed tags.
### Purpose
Enables protocol-level discovery of relays on a variety of parameters while ommitting the large footprint of metadata in the "Discovery Case"
### Schema
#### Summary
`30166` events contain only indexable tags.
#### Indexed Tags
-`d` The relay URL. The `#d` tag **must** be included in the `event.tags[]` array. Index position `1`**must** be the relay websocket URL. The URL **SHOULD** be [normalized](https://datatracker.ietf.org/doc/html/rfc3986#section-6)
-`R`: Requirements _NIP-11 "Informational Document" `nip11.limitations.payment_required`, `nip11.limitations.auth_required` and/or any other boolean value within `nip11.limitations[]` that is added in the future_
Since nostr protocol does not currently support filtering on whether an indexed tag **IS** or **IS NOT** set, to make "public" and "no auth" relays discoverable requires a `!` flag
-`g`: `NIP-66` leverages a draft NIP for geo tags, which is backwards compatible with `0` collisions for legacy `g` tags from `NIP-52`. See [YAGT](https://github.com/nostr-protocol/nips/pull/952)
When a monitor flags check support [`c` tag] in their `10166` kind, related indexable fields **SHOULD** be present in their published `30166` event kinds.
- Relay Monitors that publish `30166` events **SHOULD** at a minimum be conducting `rtt` checks, namely websocket `open`, so that clients can determine liveness.
-`k` indexable tags are not associated to any other standard and thus cannot be flagged for support in `10166` until `NIP-11` support kind flagging.
`30066` is a `NIP-33` Parameterized-Replaceable Event [PRE], referred to as a "Relay Metadata" event. These events store the existence and optionally some data relating to the relay. These events can be published by a monitor or self published by relay operators
To store useful, computationally expensive data derived from checks and other metadata about relays. This data is found by filtering the normalized relay URL with the `d` tag. Determining liveness `30066` can be used by filtering against `since` with respect to the `frequency` value set in a **Relay Monitor's**`10166` event kind.
-`d` The relay URL. The `#d` tag **MUST** be included in the `event.tags[]` array. Index position `1`**SHOULD** be the relay websocket URL. The URL **SHOULD** be [normalized](https://datatracker.ietf.org/doc/html/rfc3986#section-6)
```json
[ "d", "wss://history.nostr.watch/"]
```
-`30066` events **MAY** contain any of the indexable tags included in `30166` kind events (See instructions for this case in `10166`'s schema, specifically under `k`)
#### Unindexed Tags
-`rtt` group contains key/value pairs that describe the round trip time of a particular operation. Values at position `2...`**SHOULD** treated as an array by consumers. This array can be used to **mathematically** find `min`, `max`, `average` and `median` values. For example `Math.min(...["190", "201", "540"].map( n => parseInt(n) ))`. Some obvious index `1` keys are websocket `open`, `read` and `write` round-trip times, as well as `nip11` https request round-trip time.
-`ssl` group contains key/value pairs that describe the checked status of a relay's SSL Certificate. Index `1` keys for `ssl` can be atomized and should be one of the following `valid_from`, `valid_to`, `subject_alt_name`, `fingerprint`, `fingerprint256`, `fingerprint512`, `ext_key_usage`, `exponent`, `serial_number`, `modulus` and/or `pem_encoded`. There **SHOULD NOT** be duplicate keys.
-`dns` group contains key/value pairs that describe a DNS lookup for the relay from the perspective of a given monitor. It can provide insights on other meta data in the event. Index `1` keys for `dns` can be atomized and should be one of the following `as`, `asn`, `ipv4` or `ipv6`. There **MAY** be duplicate keys.
-`nip11` group is a special group that extracts specific values as long as they are no more than 1 level deep and do not contain arrays of objects. This data **MAY** be duplicated as stringified `NIP-11` JSON in content.
```json
["nip11", "name", "A nostr relay"],
["nip11", "description", "It stores notes and other stuff"],
-`count` Meta values for arbitrary counts related to a relay. Index position `1` is the value expressed as the string representation of an integer or float. Index position `2` is the key and describes the count, such as `total_users` or `total_events`. Index position `3`**MAY** be set and defines the "period" in seconds that the count at position `2` was calculated. Counts **SHOULD** only be included when representing unique or computationally expensive counts, not ones that can be easily achieved via `NIP-45` counts. A count's key **SHOULD** be **snake case**. There **MAY** be zero (0) to many count tags.
-`other`: A group for other type checks that could be a derivative of another check or unassociated to a specific check. A good example is `network` which is is determined by parsing the URL to attempt to identify which network it can be found on, and would likely already be in the monitor's cache as it was determined for discoverability purposes.
For self-reported `30066` events by "Relay Operators", certain tags **SHOULD NOT** be self-published or otherwised ignored by clients if present. Please reference the table below.
A _Relay Monitor_ publishes `30066` events exclusively when a relay is reachable. This approach ensures that the last known active state of the relay is maintained and recorded in `created_at` value of event. Based on this data, several inferences can be drawn about the relay's status and characteristics.
1. Clients and/or users can set a custom threshold to establish a cutoff timestamp for filtering events using `since`. This timestamp helps in identifying which relays are currently online. Selecting a lower threshold value results in a stricter criterion for relay uptime, making the filter more sensitive to brief downtimes. Conversely, choosing a higher threshold value creates a more lenient filter, allowing relays with longer downtimes to still be considered as online.
2. In determining whether a relay is 'dead,' the decision is solely at the discretion of the client or user. The are responsible for setting and applying arbitrary thresholds using `until` filters or post-processing to make this determination. This approach underscores that the classification of a relay as 'dead' is a subjective decision, varying according to each client's or user's assessment criteria, rather than a fixed status provided by the monitor.
3. For [Relay Metadata](#k30066) events that have become outdated, the retained data points remain valuable. They offer insights and information about the relay's characteristics, performance and impact on the network, which might not be currently accessible due to the relay being offline.
- Relay Monitors **SHOULD** run checks and publish events according to the `frequency` value set in their respective `10166` kind event.
- If a relay monitor publishes both `30166` and `30066` kind events, they **SHOULD** publish both on every check.
- Clients **SHOULD** only use monitors reporting `rtt` values for websockets (particularly `open`) for determining the "liveness" or "deadness" of a relay.
- Clients **SHOULD** consider the `frequency` value in a monitor's `10166` when trying to reach determination of "liveness".
-`NIP-11` values are provided as means to filter and discover relays, however ****SHOULD NOT** be used as a replacement to `NIP-11`.
- A particular relay's retention policy could conflict with subjective thresholds used in determination of "liveness" or "deadness" of relays and so care **SHOULD** be taken with regards to chosen relays for `NIP-66` by both monitors and consumers.
The data in `30066`**MAY** be erroneous, intentionally or otherwise. Where accuracy is required, the data in `30066` events **SHOULD** be subscribed to by populating the `authors` filter array with the public keys of subjectively **trusted monitors** and where security or privacy is a concern any republished values (such as NIP-11 values) should instead be attained from the source (https). All data is for informational purposes and to make finding and filtering through relays through nostr a possiblity.
1.**Geographic Relay Discovery**: Identify relays situated near a specific geographic location or within a particular country, facilitating localized network interactions.
2.**NIP Support Filtering**: Search for relays based on their support for specific Nostr Improvement Proposals (NIPs), ensuring compatibility with desired protocol features.
3.**Accessibility Search**: Locate relays that are free to use, helping users find cost-effective or no-cost options for their network interactions.
4.**Real-Time Status Monitoring**: Utilize a status client to display up-to-date statuses of various relays, providing insights into their current operational state.
5.**Relay Network Analysis**: Analyze connections and patterns between relays using their IP addresses, aiding in network topology understanding and security assessments.
6.**Error Detection in Relay Listings**: Spot and rectify erroneous entries in relay lists, ensuring the accuracy and reliability of relay data.
7.**Performance Benchmarking**: Compare relays based on performance metrics like round-trip times and uptime, aiding in the selection of the most efficient relays for specific needs.
8.**Security and Compliance Checks**: Evaluate relays for adherence to security standards and regulatory compliance, essential for users with specific security and privacy requirements.
9.**Language and Content Filtering**: Identify relays catering to specific languages or content types, enabling users to engage in a more targeted and relevant social networking experience.
10.**Data-Driven Relay Selection**: Make informed choices about which relays to connect to, based on comprehensive metadata including user counts, event frequencies, network types and more.