clone

every nostr nip as a chapter of an illustrated, early-2000s printed game manual

main
nip.guide / site / nips / 12.html
12.html 9.2K
1<!DOCTYPE html>2<html lang="en">3<head>4<meta charset="utf-8">5<meta name="viewport" content="width=device-width, initial-scale=1">6<title>NIP-12 - Generic Tag Queries — Nostr Instruction Manual</title>7<meta name="description" content="NIP-12: generic single-letter tag queries. Merged into NIP-01 in 2023. This page explains what it defined and where the rules live now.">8<link rel="preload" href="../assets/fonts/michroma-400-latin.woff2" as="font" type="font/woff2" crossorigin>9<link rel="preload" href="../assets/fonts/exo2-var-latin.woff2" as="font" type="font/woff2" crossorigin>10<link rel="preload" href="../assets/fonts/sairacondensed-600-latin.woff2" as="font" type="font/woff2" crossorigin>11<link rel="preload" href="../assets/fonts/sairacondensed-700-latin.woff2" as="font" type="font/woff2" crossorigin>12<link rel="preload" href="../assets/fonts/sairacondensed-500-latin.woff2" as="font" type="font/woff2" crossorigin>13<link rel="preload" href="../assets/fonts/sharetechmono-400-latin.woff2" as="font" type="font/woff2" crossorigin>14<link rel="preload" href="../assets/fonts/exo2-400i-latin.woff2" as="font" type="font/woff2" crossorigin>15<link rel="icon" href="../assets/favicon.svg" type="image/svg+xml">16<link rel="stylesheet" href="../assets/manual.css">17</head>18<body>1920<svg width="0" height="0" style="position:absolute">21 <defs>22 <marker id="arr" markerWidth="9" markerHeight="9" refX="7" refY="4.5" orient="auto">23 <path d="M1,1 L8,4.5 L1,8 Z" fill="#f26a00"/>24 </marker>25 <marker id="arrb" markerWidth="9" markerHeight="9" refX="7" refY="4.5" orient="auto">26 <path d="M1,1 L8,4.5 L1,8 Z" fill="#2e5f9e"/>27 </marker>28 </defs>29</svg>3031<div class="page">32 <span class="staple s1"></span><span class="staple s2"></span>3334 <header class="band">35 <a class="logo" href="../index.html">NOSTR<b>▸</b>PROTOCOL MANUAL</a>36 <span class="booklet-note">Chapter 12 - Core</span>37 </header>38 <nav class="tabs">39 <a href="../index.html">Contents</a>40 <a href="#overview" class="on">Overview</a>41 <a href="#spec">Spec</a>42 <a href="#examples">Examples</a>43 <a href="#history">History</a>44 </nav>4546 <div class="chapter">47 <div class="nipno" data-n="12">12</div>48 <div class="titles">49 <div class="kicker">Nostr Implementation Possibility - Hex № 12</div>50 <h1>Generic Tag Queries</h1>51 <p class="sub">This chapter is closed. NIP-12 once defined generic single-letter tag filters. That rule is now part of the core protocol in <a href="01.html">NIP-01</a>.</p>52 </div>53 <div class="stamp merged">Merged</div>54 </div>5556 <main class="spread">57 <div class="main">5859 <h2 class="bar" id="overview"><span class="num">1</span> Overview</h2>60 <p>NIP-12 was a short extension to the filter object. <a href="01.html">NIP-01</a> already let a client query events by the <code>e</code> tag or the <code>p</code> tag. NIP-12 opened this up. A client could query by any single-letter tag, using a filter key such as <code>"#r"</code> or <code>"#t"</code>.</p>61 <p>Relays only indexed tags whose name was a single letter, <code>a</code>-<code>z</code> or <code>A</code>-<code>Z</code>. This kept relay indexes small. Applications were free to use longer tag names for their own data without forcing every relay to index them.</p>6263 <div class="box hint">64 <span class="tag">Merged</span>65 <p>NIP-12 is closed and carries no separate rules of its own anymore. Every rule it defined now lives in <a href="01.html#tags">NIP-01, section 3 (Tags)</a> and <a href="01.html#messages">section 5 (Client ↔ Relay Messages)</a>. Read this page for history, then read NIP-01 for the current spec.</p>66 </div>6768 <h2 class="bar" id="spec"><span class="num">2</span> What NIP-12 Defined</h2>69 <p>NIP-12 stated three rules, restated here in Simplified Technical English:</p>70 <ul>71 <li>A filter key that starts with <code>#</code>, followed by one letter, is a tag query. Example: <code>"#r"</code>.</li>72 <li>The value of a tag-query key must be an array of strings. A matching event needs only one tag value in common with the filter.</li>73 <li>Relays index only single-letter tag names. Longer tag names are stored with the event but are not queryable. Tag names are case-sensitive: <code>"#t"</code> and <code>"#T"</code> are different queries.</li>74 </ul>75 <p>NIP-12 also listed motivating use cases: an <code>r</code> tag for referencing a URL, a <code>g</code> tag for a geohash, and a <code>t</code> tag for a hashtag. It did not standardize any specific tag name for any purpose.</p>7677 <h3>Where It Lives Now</h3>78 <p>NIP-01 absorbed all of this. Its Tags section explains that relays index every tag whose name is one English letter, and shows the filter shape <code>{"#e": [&lt;event id&gt;]}</code> as the general pattern. Its Filters section lists <code>"#&lt;letter&gt;"</code> directly inside the filter object. There is no remaining behavior that is specific to NIP-12; it is now an ordinary part of the base protocol.</p>7980 <h2 class="bar" id="examples"><span class="num">3</span> Historical Example</h2>81 <p>This is the filter example NIP-12 originally used to explain generic tag queries. It still works exactly like this under NIP-01 today.</p>82 <div class="crt">83 <div class="titlebar">Example - filter with a generic tag query</div>84<pre>{85 <span class="k">"kinds"</span>: [1],86 <span class="k">"#r"</span>: [<span class="s">"foo"</span>, <span class="s">"bar"</span>]87}</pre>88 </div>89 <p>This filter matches any kind-1 event with an <code>r</code> tag whose value is <code>"foo"</code> or <code>"bar"</code>.</p>9091 <h2 class="bar" id="history"><span class="num">4</span> Version History</h2>92 <ul class="patchnotes">93 <li><span class="ver">Closed</span><span class="when">2023-08-13</span>Merged into <a href="01.html">NIP-01</a> along with <a href="16.html">NIP-16</a>, <a href="20.html">NIP-20</a>, and <a href="33.html">NIP-33</a> (PR <a href="https://github.com/nostr-protocol/nips/pull/703">#703</a>). All four were already "final, mandatory" — folding them into the root spec meant a client or relay only had to read one document to reach baseline compliance.</li>94 <li class="minor"><span class="ver">2023</span><span class="when">2023-11-15</span>Repo-wide cleanup removed the per-file author badge from the now-stub page.</li>95 <li><span class="ver">2023</span><span class="when">2023-07-09</span>jiftechnify clarified that tag names are case-sensitive.</li>96 <li><span class="ver">2022</span><span class="when">2022-07-10</span>fiatjaf restricted indexing to single-letter tags only, to keep relay indexes small.</li>97 <li><span class="ver">Origin</span><span class="when">2022-05-01</span>fiatjaf published NIP-12, authored with scsibug, in the newly migrated <code>nostr-protocol/nips</code> repository.</li>98 </ul>99100 <div class="credits">101 <h3 class="cardhead">Original Proposal - Credits</h3>102 <table>103 <tr><td>Authors</td><td>scsibug, fiatjaf</td></tr>104 <tr><td>First commit</td><td>2022-05-01 — “migrate nips from main nostr repo.”</td></tr>105 <tr><td>Status</td><td><span class="chip final">final</span> <span class="chip mandatory">mandatory</span> — merged, no longer a standalone document</td></tr>106 <tr><td>Source</td><td><a href="https://github.com/nostr-protocol/nips/blob/master/12.md">12.md on GitHub</a> - <a href="https://github.com/nostr-protocol/nips/commits/master/12.md">full change history</a></td></tr>107 </table>108 </div>109110 <h2 class="bar"><span class="num">5</span> See Also</h2>111 <ul>112 <li><a href="01.html">NIP-01</a> — the current, canonical home of generic tag queries and the full filter object.</li>113 <li><a href="16.html">NIP-16</a> — event treatment (kind ranges), merged the same day as NIP-12.</li>114 <li><a href="20.html">NIP-20</a> — command results, merged the same day as NIP-12.</li>115 <li><a href="33.html">NIP-33</a> — addressable events, merged the same day as NIP-12.</li>116 </ul>117 </div>118119 <aside>120 <div class="cartridge">121 <div class="inner">122 <h3 class="cardhead">Spec Card</h3>123 <div class="lights"><span class="led on"></span><span class="led on"></span><span class="led on"></span></div>124 <dl>125 <dt>Status</dt><dd><span class="chip final">final</span><span class="chip mandatory">mandatory</span></dd>126 <dt>Defined</dt><dd>generic <code>"#&lt;letter&gt;"</code> tag filters</dd>127 <dt>Now lives in</dt><dd><a href="01.html#tags">NIP-01 §3, §5</a></dd>128 <dt>Requires</dt><dd><a href="01.html">NIP-01</a></dd>129 <dt>First commit</dt><dd>2022-05-01</dd>130 <dt>Merged</dt><dd>2023-08-13 (PR #703)</dd>131 <dt>Last updated</dt><dd>2023-11-15</dd>132 </dl>133 </div>134 </div>135 </aside>136 </main>137138 <nav class="navbtns">139 <a href="11.html">◀ NIP-11: Relay Information Document</a>140 <a href="13.html">NIP-13: Proof of Work ▶</a>141 </nav>142143 <footer class="pagefoot">144 <a href="../index.html">Nostr Protocol Manual</a>145 <span class="pageno">NIP 12 / F4</span>146 </footer>147</div>148149<script src="../assets/webmcp.js" defer></script>150</body>151</html>