Nostr.Event.ExternalReaction (Nostr Lib v0.2.1) (event) (nip25) (nip73)

View Source

External content reaction (kind 17).

Defined in NIP-25: https://github.com/nostr-protocol/nips/blob/master/25.md

Used when reacting to non-nostr content like websites, podcasts, videos, etc. Uses NIP-73 external content k + i tags to reference the content.

Examples

Reacting to a website:

{
  "kind": 17,
  "content": "⭐",
  "tags": [
    ["k", "web"],
    ["i", "https://example.com"]
  ]
}

Reacting to a podcast:

{
  "kind": 17,
  "content": "+",
  "tags": [
    ["k", "podcast:guid"],
    ["i", "podcast:guid:917393e3-1b1e-5cef-ace4-edaa54e1f810", "https://fountain.fm/..."]
  ]
}

Summary

Functions

Creates a new external content reaction event (kind 17).

Parses a kind 17 event into an ExternalReaction struct.

Types

external_id()

@type external_id() :: %{id: binary(), hint: binary() | nil}

t()

@type t() :: %Nostr.Event.ExternalReaction{
  content_type: binary() | nil,
  emoji_url: binary() | nil,
  event: Nostr.Event.t(),
  identifiers: [external_id()],
  reaction: String.t(),
  user: binary()
}

Functions

create(content_type, identifier, reaction \\ "+", opts \\ [])

@spec create(
  content_type :: binary(),
  identifier :: binary(),
  reaction :: String.t(),
  opts :: Keyword.t()
) :: t()

Creates a new external content reaction event (kind 17).

Arguments

  • content_type - the type of content (e.g., "web", "podcast:guid")
  • identifier - the content identifier (URL, GUID, etc.)
  • reaction - the reaction content (+, -, emoji, or :shortcode:)
  • opts - keyword options:
    • :pubkey - pubkey of the reactor (required for unsigned events)
    • :hint - optional hint URL for the identifier
    • :emoji_url - URL for custom emoji (when reaction is :shortcode:)
    • :tags - additional tags to include
    • :created_at - timestamp (defaults to now)

Examples

# React to a website
ExternalReaction.create("web", "https://example.com", "⭐")

# React to a podcast with hint
ExternalReaction.create(
  "podcast:guid",
  "podcast:guid:917393e3-1b1e-5cef-ace4-edaa54e1f810",
  "+",
  hint: "https://fountain.fm/show/QRT0l2EfrKXNGDlRrmjL"
)

parse(event)

@spec parse(event :: Nostr.Event.t()) :: t() | {:error, String.t(), Nostr.Event.t()}

Parses a kind 17 event into an ExternalReaction struct.