NIP-25

    Reactions

    draft optional

    A reaction is a kind 7 event that is used to indicate user reactions to other events. A reaction's content field MUST include user-generated-content indicating the value of the reaction (conventionally +, -, or an emoji).

    A reaction with content set to + or an empty string MUST be interpreted as a "like" or "upvote". A reaction with content set to - MUST be interpreted as a "dislike" or "downvote".

    A reaction with content set to an emoji or NIP-30 custom emoji SHOULD NOT be interpreted as a "like" or "dislike". Clients MAY instead display this emoji reaction on the post.

    Tags

    There MUST be always an e tag set to the id of the event that is being reacted to. The e tag SHOULD include a relay hint pointing to a relay where the event being reacted to can be found. If a client decides to include other e, which not recommended, the target event id should be last of the e tags.

    There SHOULD be a p tag set to the pubkey of the event being reacted to. If a client decides to include other p tags, which not recommended, the target event pubkey should be last the p tags.

    If the event being reacted to is an addressable event, an a SHOULD be included together with the e tag, it must be set to the coordinates (kind:pubkey:d-tag) of the event being reacted to.

    The reaction SHOULD include a k tag with the stringified kind number of the reacted event as its value.

    The e and a tags SHOULD include relay and pubkey hints. The p tags SHOULD include relay hints.

    The reaction event MAY include a k tag with the stringified kind number of the reacted event as its value.

    Example code

    func make_like_event(pubkey: String, privkey: String, liked: NostrEvent, hint: String) -> NostrEvent {
        var tags: [[String]] = []
        tags.append(["e", liked.id, hint, liked.pubkey])
        tags.append(["p", liked.pubkey, hint])
        tags.append(["k", String(liked.kind)])
        let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
        ev.calculate_id()
        ev.sign(privkey: privkey)
        return ev
    }
    

    Reactions to a website

    If the target of the reaction is a website, the reaction MUST be a kind 17 event and MUST include an r tag with the website's URL.

    {
      "kind": 17,
      "content": "⭐",
      "tags": [
        ["r", "https://example.com/"]
      ],
      // other fields...
    }
    

    URLs SHOULD be normalized, so that reactions to the same website are not omitted from queries. A fragment MAY be attached to the URL, to react to a section of the page. It should be noted that a URL with a fragment is not considered to be the same URL as the original.

    Custom Emoji Reaction

    The client may specify a custom emoji (NIP-30) :shortcode: in the reaction content. The client should refer to the emoji tag and render the content as an emoji if shortcode is specified.

    {
      "kind": 7,
      "content": ":soapbox:",
      "tags": [
        ["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"]
      ],
      // other fields...
    }
    

    The content can be set only one :shortcode:. And emoji tag should be one.

    Comments

    Sign in to comment