Pick just 3 fields and filters as required

This commit is contained in:
arthurfranca 2023-09-22 10:49:27 -03:00
parent 1669f2d751
commit 6da937507c

82
17.md
View File

@ -10,76 +10,64 @@ Relays may attach event metadata to requested events.
## Motivation ## Motivation
To save relay bandwidth while helping clients show event metadata estimates faster. To save relay and client bandwidth.
## Fields ## Fields
All fields are optional and live inside an extra nip17 key. All extra fields live inside an extra `meta` key.
Some fields only make sense for a subset of kinds.
New fields may be added to this NIP later.
### Returned Event Example ### Returned Event Example
```js ```js
{ {
"kind": ..., // 1, 30023, 0, ... "kind": ..., // 1, 30023, 0, ...
..., // regular keys ..., // regular event fields
"nip17": { "meta": {
"country": "US", // ISO 3166-1 alpha-2 code extracted from NIP-32 label (geohash/country/... l tag) or detected by IP // v REQUIRED v
"followers": 500, // sent with kind 0 events "isRoot": true, // true when the event holds no `e` nor `a` tags
"language": "en", // ISO 639-1 code of detected event.content language "language": "en", // ISO 639-1 code of detected using event.content language
"reactions": { // ISO 3166-1 alpha-2 code. Detection strategies:
"+": 8, // kind 7 "+" reaction count (should be the sum of "+" and all emoji reactions) // - detected by IP
"-": 0, // kind 7 "-" reaction count // - extracted from "g" (geohash) tag
"🤙️": 10 // kind 7 specific emoji reaction count // - selecting one of the countries that use the detected "language" as the main one
}, "country": "US",
"relays": ["wss://relay.url"], // event found originally on these relays // ^ REQUIRED ^
// v OPTIONAL v
"replies": 10, // direct descendant kind 1 reply count "replies": 10, // direct descendant kind 1 reply count
"reposts": 20, // NIP-18 repost count "reposts": 20, // NIP-18 repost count
"views": 900, // request count from different IPs, device ids or pubkeys "views": 900, // request count from different IPs, device ids or pubkeys
"followers": 500, // sent with kind 0 events; the value is 0 otherwise
"zaps": 7, // kind 9735 count "zaps": 7, // kind 9735 count
"zap_amount": 10000 // kind 9735 millisats amount sum "zap_amount": 10000, // kind 9735 millisats amount sum
"reactions": {
"+": 12, // kind 7 "+" reaction count (should be the sum of "+" and all emoji reactions)
"-": 3, // kind 7 "-" reaction count
"🤙️": 10 // kind 7 specific emoji reaction count
},
"relays": ["wss://relay.url"] // event found originally on these relays
// ^ OPTIONAL ^
} }
} }
``` ```
## Filter Extensions ## Filters
Clients can use extra filter attributes when requesting events. They additional attributes Relays MUST support extra `REQ` message's filter attributes inside the `meta` field. Multiple
are limited to a subset of the NIP-17 fields and are namespaced in the `nip17` filter key. fields inside the `meta` key are considered "AND" conditions.
Relays should use NIP-11 `supported_nip_extensions` when supporting an extension. #### Is Root
For example: { "supported_nips": [17], "supported_nip_extensions": ["nip17language", "nip17country"] } `["REQ", <sub_id>, { "kinds": [1], ..., "meta": { "isRoot": false } }]`
### NIP-17country ### Language
Filter by country. The array is considered "OR" condition.
Example request: `["REQ", <sub_id>, { "kinds": [1], ..., "nip17": { "country": ["US", "GB"] } }]` `["REQ", <sub_id>, { "kinds": [1], ..., "meta": { "language": ["en", "pt"] } }]`
### NIP-17followers #### Country
Filter by number of followers. The array is considered "OR" condition.
Example request: `["REQ", <sub_id>, { "kinds": [0], ..., "nip17": { "followers": ">100000" } }]` `["REQ", <sub_id>, { "kinds": [1], ..., "meta": { "country": ["US", "GB"] } }]`
### NIP-17language
Filter by language.
Example request: `["REQ", <sub_id>, { "kinds": [1], ..., "nip17": { "language": ["en", "pt"] } }]`
### NIP-17reactions
Filter by number of reactions. Just `reactions.+` and `reactions.-` fields.
Example request: `["REQ", <sub_id>, { "kinds": [1], ..., "nip17": { "reactions.+": ">1000", "reactions.-": "<1000" } }]`
### NIP-17replies
Filter by number of replies.
Example request: `["REQ", <sub_id>, { "kinds": [1], ..., "nip17": { "replies": ">100" } }]`