Nostr. Event. Label
(Nostr Lib v0.2.1)
(event)
(nip32)
View Source
Label (Kind 1985)
Attach labels to events, pubkeys, relays, or topics for distributed moderation, content classification, license assignment, and other labeling use cases.
Label Structure
Labels use two tag types:
Ltags define label namespaces (e.g., "license", "com.example.ontology")ltags define actual labels with a namespace mark
Target Types
Labels can target:
- Events (
etags) - Pubkeys (
ptags) - Addressable events (
atags) - Relays (
rtags) - Topics (
ttags)
Self-Labeling
L and l tags can be added to non-1985 events for self-reporting.
In that case, the labels refer to the event itself.
Defined in NIP 32 https://github.com/nostr-protocol/nips/blob/master/32.md
Summary
Types
Functions
Creates a label event (kind 1985).
Arguments
labels- List of labels. Each label can be:{label, namespace}tuple- Just a string (uses "ugc" as default namespace)
targets- Map with target keys::events- List of event IDs or{event_id, relay_hint}tuples:pubkeys- List of pubkeys or{pubkey, relay_hint}tuples:addresses- List of addresses or{address, relay_hint}tuples:relays- List of relay URLs:topics- List of topics/hashtags
opts- Optional event arguments
Options
:content- Explanation for the labeling:pubkey- Event author pubkey:created_at- Event timestamp
Examples
# Label an event with a license
Label.create(
[{"MIT", "license"}],
%{events: ["abc123..."]}
)
# Label pubkeys with a topic association
Label.create(
[{"permies", "#t"}],
%{pubkeys: [{"pubkey1", "wss://relay.example.com"}, "pubkey2"]}
)
# Moderation label with explanation
Label.create(
[{"approve", "nip28.moderation"}],
%{events: ["event_id"]},
content: "Reviewed and approved for channel"
)
@spec parse(Nostr.Event.t()) :: t()
Parses a kind 1985 event into a Label struct.