Skip to content
GitHubRSS

NIP-11: Relay Information

NIP-11 defines a standard for relays to publish their capabilities and metadata as a JSON document accessible via HTTP(S) at the relay’s WebSocket URL.

When a client sends an HTTP GET request with Accept: application/nostr+json to a relay’s URL, compliant relays return a JSON document containing:

FieldTypeDescription
namestringRelay name
descriptionstringHuman-readable description
pubkeystringRelay operator’s public key
contactstringContact information
supported_nipsint[]List of supported NIP numbers
softwarestringSoftware implementation URL
versionstringSoftware version string
limitationobjectRate limits, message sizes, subscription limits
retentionobject[]Data retention policies
relay_countriesstring[]ISO 3166-1 country codes
language_tagsstring[]BCP 47 language tags
tagsstring[]Relay category tags
posting_policystringURL to posting policy
payments_urlstringURL to payment information

The Nip11 class in bigbrotr.nips.nip11 handles:

  1. Fetching — HTTP GET with Accept: application/nostr+json header. Handles timeouts, SSL errors, connection failures, and non-JSON responses.
  2. Parsing — JSON parsing with field validation. Extracts software name and version from the software URL.
  3. Storage — Produces a Metadata object with MetadataType.NIP11_INFO containing the parsed data.

NIP-11 fetch methods never raise exceptions. Instead, the result object includes a logs.success flag:

result = await nip11.fetch(relay_url)
if result.logs.success:
# Use result.metadata
else:
# Log failure, skip relay

This pattern ensures that one relay’s failure never crashes the monitoring cycle.

The software field in NIP-11 documents is typically a URL like git+https://github.com/hoytech/strfry. BigBrotr extracts the software name from the URL path, enabling the relay_software_counts materialized view to show the distribution of relay implementations across the network.

Relay → HTTP GET → NIP-11 JSON → Parse → Metadata(type=NIP11_INFO) → relay_metadata_insert_cascade

The NIP-11 metadata is stored content-addressed: if a relay’s NIP-11 document hasn’t changed since the last check, the same SHA-256 hash is produced and no duplicate metadata row is created. Only the relay_metadata junction row is updated with the new generated_at timestamp.