Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sandwichfarm/nostr-watch/llms.txt
Use this file to discover all available pages before exploring further.
@nostrwatch/publisher handles the construction and transport of NIP-66 events — the standardized Nostr events that relay monitors use to announce themselves and share relay health data. Rather than building raw signed JSON objects by hand, you instantiate the appropriate kind class, call generateEvent(), sign it with signEvent(), and hand the result to Publisher for delivery. The package is used internally by @nostrwatch/announce during monitor boot and by the relaymon daemon for each relay check cycle.
@nostrwatch/publisher is an internal monorepo package. It is not published to npm. Add it as a workspace dependency with pnpm add @nostrwatch/publisher --filter @nostrwatch/your-package.Installation
nostr-tools@2.11.0 must be installed in the consuming package.
Quick start
Core API
Publisher
Publisher handles transport — it connects to relays and calls pool.publish via a nostr-tools SimplePool.
| Parameter | Type | Description |
|---|---|---|
pubkey | string | 64-char hex public key of the signing identity |
relays | string[] | WebSocket relay URLs to publish to |
config | Config | Optional — no active configuration properties in current implementation |
publishEvent(signedEvent) — Publishes one signed event to all configured relays using Promise.any. Resolves as soon as any relay accepts the event; throws if all relays reject.
publishEvents(signedEvents) — Publishes each event in the async iterable in sequence, returning an array of results.
Event base class
All kind classes extendEvent. You can subclass it directly to implement event types not covered by the built-in kind classes:
_generateEvent(data) in your subclass to assemble the tags and content fields for your custom event kind. Call generateEvent() before signEvent() — signEvent throws if generateEvent has not been called first.
Event kind classes
All kind classes extendEvent and accept pubkey: string in their constructor.
Sign the event
signEvent calls finalizeEvent and verifyEvent from nostr-tools. It throws if signature verification fails.Kind30166 — NIP-66 relay status
Publishes a kind 30166 relay status event. Thecheck parameter is assembled from nocap check results and maps relay health data — RTT timings, NIP-11 info, SSL validity, DNS records, geo data — into the NIP-66 event tag structure.
relaymon produces one kind 30166 event per relay. See raw NIP-66 events for the full list of event kinds and their tag structures.
Kind10166 — NIP-66 monitor registration
Publishes a kind 10166 monitor announcement event. This declares the monitor’s capabilities — check frequency, supported networks, check types, timeouts, and geo metadata — to the network.Kind10002 — NIP-65 relay list
Publishes a NIP-65 kind 10002 relay list event. Used to announce which relays a monitor publishes to.Kind0 — NIP-01 user metadata
Publishes a kind 0 user metadata event. Used by@nostrwatch/announce to publish the monitor’s public profile.
Builder helpers
Low-level helpers for constructing NIP-66 event fields manually. The kind classes use these internally; reach for them only when building a custom event kind not covered by the built-in classes:Monitor announcements with @nostrwatch/announce
@nostrwatch/announce wraps @nostrwatch/publisher to publish the three events a monitor needs on every boot — kind 10166 (monitor registration), kind 10002 (relay list), and kind 0 (profile) — in a single call sequence.
@nostrwatch/announce is also an internal monorepo package. Add it with pnpm add @nostrwatch/announce --filter @nostrwatch/your-package. Peer dependency: nostr-tools@2.1.4.AnnounceMonitor options
| Option | Type | Required | Description |
|---|---|---|---|
relays | string[] | Yes | Relays the monitor publishes NIP-66 events to |
userDataRelays | string[] | No | Relays for kind 0 and 10002 events; defaults to ['wss://purplepag.es', 'wss://user.kindpag.es'] |
frequency | string | No | Check interval in seconds as a string (e.g., '3600') |
networks | string[] | No | Network types the monitor covers (e.g., ['clearnet', 'tor']) |
checks | string[] | No | Check types to declare; pass ['all'] to expand to all supported checks |
timeouts | object | No | Per-check timeout configuration |
geo | object | No | Monitor geolocation data |
profile | object | No | NIP-01 profile fields for the kind 0 event |
generate(), call sign(sk) and then publish(). publish() routes kind 0 and 10002 to userDataRelays and kind 10166 to relays.
When to use publisher vs nocap-route66
Use publisher
When you need to sign and broadcast NIP-66 events to the network — relay status updates, monitor registration, relay lists, or profile metadata. Publisher handles construction and transport.
Use nocap + route66
When you need to perform relay checks and read or aggregate existing NIP-66 events from the network. nocap probes relays; route66 queries and stores the results.
CheckData objects that Kind30166.generateEvent() consumes, and route66 aggregates the kind 30166 events that publisher emits.