upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/12.md
diff options
context:
space:
mode:
authorfiatjaf <faitjaf@gmail.com>2022-05-01 07:48:57 -0300
committerfiatjaf <faitjaf@gmail.com>2022-05-01 07:48:57 -0300
commitf25c7e672c23ca5463fa5c0fcb5e5f424d956862 (patch)
tree597462ec02ed56ef53f268279a31f62edd3f37eb /12.md
migrate nips from main nostr repo.
Diffstat (limited to '12.md')
-rw-r--r--12.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/12.md b/12.md
new file mode 100644
index 0000000..1d5ba1f
--- /dev/null
+++ b/12.md
@@ -0,0 +1,38 @@
1NIP-12
2======
3
4Generic Tag Queries
5-------------------
6
7`draft` `optional` `author:scsibug`
8
9Relays may support subscriptions over arbitrary tags. `NIP-01` requires relays to respond to queries for `e` and `p` tags. This NIP allows any tag present in an event to be queried.
10
11The `<filters>` object described in `NIP-01` is expanded to contain arbitrary keys with a `#` prefix. Any key in a filter beginning with `#` is a tag query, and MUST have a value of an array of strings. The filter condition matches if the event has a tag with the same name, and there is at least one tag value in common with the filter and event. The tag name is the first element of a tag array with the initial `#` removed, and the tag value is the second element. Subsequent elements are ignored for the purposes of tag queries.
12
13
14Example Subscription Filter
15---------------------------
16
17The following provides an example of a filter that matches events of kind `1` with a `foo` tag set to either `bar` or `baz`.
18
19```
20{
21 "kinds": [1],
22 "#foo": ["bar", "baz"]
23}
24```
25
26Client Behavior
27---------------
28
29Clients SHOULD use the `supported_nips` field to learn if a relay supports generic tag queries. Clients MAY send generic tag queries to any relay, if they are prepared to filter out extraneous responses from relays that do not support this NIP.
30
31Suggested Use Cases
32-------------------
33
34Motivating examples for generic tag queries are provided below. This NIP does not promote or standardize the use of any specific tag for any purpose.
35
36* Decentralized Commenting System: clients can comment on arbitrary web pages, and easily search for other comments, by using a `url` tag and value.
37* Location-specific Posts: clients can use a `geohash` tag to associate a post with a physical location. Clients can search for a set of geohashes of varying precisions near them to find local content.
38* Hashtags: clients can use simple `hashtag` tags to associate an event with an easily searchable topic name. Since Nostr events themselves are not searchable through the protocol, this provides a mechanism for user-driven search.