nips/32.md

177 lines
5.1 KiB
Markdown
Raw Normal View History

NIP-32
======
Labeling
--------
2023-11-16 00:42:51 +00:00
`draft` `optional`
This NIP defines two new indexable tags to label events and a new event kind (`kind:1985`) to attach those labels to existing events. This supports several use cases, including distributed moderation, collection management, license assignment, and content classification.
New Tags:
2023-11-10 16:13:04 +00:00
- `L` denotes a label namespace
- `l` denotes a label
2023-11-10 16:13:04 +00:00
Label Namespace Tag
----
2023-11-10 16:13:04 +00:00
An `L` tag can be any string, but publishers SHOULD ensure they are unambiguous by using a well-defined namespace
(such as an ISO standard) or reverse domain name notation.
2024-03-19 12:59:29 +00:00
`L` tags are RECOMMENDED in order to support searching by namespace rather than by a specific tag. The special `ugc`
2023-11-10 16:13:04 +00:00
("user generated content") namespace MAY be used when the label content is provided by an end user.
2023-11-10 16:13:04 +00:00
`L` tags starting with `#` indicate that the label target should be associated with the label's value.
This is a way of attaching standard nostr tags to events, pubkeys, relays, urls, etc.
2023-11-10 16:13:04 +00:00
Label Tag
----
2024-06-07 16:34:20 +00:00
An `l` tag's value can be any string. If using an `L` tag, `l` tags MUST include a mark matching an `L`
tag value in the same event. If no `L` tag is included, a mark SHOULD still be included. If none is
included, `ugc` is implied.
2023-11-10 16:13:04 +00:00
Label Target
----
2023-11-10 16:13:04 +00:00
The label event MUST include one or more tags representing the object or objects being
labeled: `e`, `p`, `a`, `r`, or `t` tags. This allows for labeling of events, people, relays,
or topics respectively. As with NIP-01, a relay hint SHOULD be included when using `e` and
`p` tags.
Content
-------
2024-03-19 12:59:29 +00:00
Labels should be short, meaningful strings. Longer discussions, such as for an
explanation of why something was labeled the way it was, should go in the event's `content` field.
2023-11-10 16:13:04 +00:00
Self-Reporting
-------
`l` and `L` tags MAY be added to other event kinds to support self-reporting. For events
with a kind other than 1985, labels refer to the event itself.
Example events
--------------
A suggestion that multiple pubkeys be associated with the `permies` topic.
2024-09-03 17:11:31 +00:00
```jsonc
{
"kind": 1985,
"tags": [
["L", "#t"],
["l", "permies", "#t"],
["p", <pubkey1>, <relay_url>],
["p", <pubkey2>, <relay_url>]
],
2024-09-03 17:11:31 +00:00
// other fields...
}
```
2023-11-10 16:13:04 +00:00
A report flagging violence toward a human being as defined by ontology.example.com.
2024-09-03 17:11:31 +00:00
```jsonc
{
"kind": 1985,
"tags": [
2023-06-14 00:30:26 +00:00
["L", "com.example.ontology"],
2023-11-10 16:13:04 +00:00
["l", "VI-hum", "com.example.ontology"],
["p", <pubkey1>, <relay_url>],
["p", <pubkey2>, <relay_url>]
],
2024-09-03 17:11:31 +00:00
// other fields...
2023-11-10 16:13:04 +00:00
}
```
A moderation suggestion for a chat event.
2024-09-03 17:11:31 +00:00
```jsonc
2023-11-10 16:13:04 +00:00
{
"kind": 1985,
"tags": [
["L", "nip28.moderation"],
["l", "approve", "nip28.moderation"],
["e", <kind40_event_id>, <relay_url>]
],
2024-09-03 17:11:31 +00:00
// other fields...
}
```
2023-11-10 16:13:04 +00:00
Assignment of a license to an event.
2024-09-03 17:11:31 +00:00
```jsonc
2023-11-10 16:13:04 +00:00
{
"kind": 1985,
"tags": [
["L", "license"],
["l", "MIT", "license"],
["e", <event_id>, <relay_url>]
],
2024-09-03 17:11:31 +00:00
// other fields...
2023-11-10 16:13:04 +00:00
}
```
Publishers can self-label by adding `l` tags to their own non-1985 events. In this case, the kind 1 event's author
is labeling their note as being related to Milan, Italy using ISO 3166-2.
2024-09-03 17:11:31 +00:00
```jsonc
{
"kind": 1,
"tags": [
2023-11-10 16:13:04 +00:00
["L", "ISO-3166-2"],
["l", "IT-MI", "ISO-3166-2"]
],
2023-11-10 16:13:04 +00:00
"content": "It's beautiful here in Milan!",
2024-09-03 17:11:31 +00:00
// other fields...
}
```
Author is labeling their note language as English using ISO-639-1.
2024-07-24 18:57:48 +00:00
2024-09-03 17:11:31 +00:00
```jsonc
2024-07-24 18:57:48 +00:00
{
"kind": 1,
"tags": [
["L", "ISO-639-1"],
["l", "en", "ISO-639-1"]
],
"content": "English text",
2024-09-03 17:11:31 +00:00
// other fields...
2024-07-24 18:57:48 +00:00
}
```
Other Notes
-----------
When using this NIP to bulk-label many targets at once, events may be requested for deletion using [NIP-09](09.md) and a replacement
may be published. We have opted not to use addressable/replaceable events for this due to the
complexity in coming up with a standard `d` tag. In order to avoid ambiguity when querying,
publishers SHOULD limit labeling events to a single namespace.
2023-06-14 00:30:26 +00:00
Before creating a vocabulary, explore how your use case may have already been designed and
imitate that design if possible. Reverse domain name notation is encouraged to avoid
namespace clashes, but for the sake of interoperability all namespaces should be
considered open for public use, and not proprietary. In other words, if there is a
namespace that fits your use case, use it even if it points to someone else's domain name.
2023-06-14 16:43:03 +00:00
Vocabularies MAY choose to fully qualify all labels within a namespace (for example,
`["l", "com.example.vocabulary:my-label"]`. This may be preferred when defining more
formal vocabularies that should not be confused with another namespace when querying
without an `L` tag. For these vocabularies, all labels SHOULD include the namespace
(rather than mixing qualified and unqualified labels).
2023-11-10 16:13:04 +00:00
A good heuristic for whether a use case fits this NIP is whether labels would ever be unique.
For example, many events might be labeled with a particular place, topic, or pubkey, but labels
with specific values like "John Doe" or "3.18743" are not labels, they are values, and should
be handled in some other way.
2024-04-23 18:34:17 +00:00
Appendix: Known Ontologies
2024-09-03 17:11:31 +00:00
--------------------------
2024-04-23 18:34:17 +00:00
Below is a non-exhaustive list of ontologies currently in widespread use.
2024-06-02 23:19:42 +00:00
- [social.ontolo.categories](https://ontolo.social/)