upleb.uk

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

summaryrefslogtreecommitdiff
path: root/45.md
diff options
context:
space:
mode:
authorcodytseng <codytseng@outlook.com>2023-04-12 23:18:22 +0800
committercodytseng <codytseng@outlook.com>2023-04-12 23:18:22 +0800
commit9ef39553e464d1ecd656f57b615ce1aa72c39176 (patch)
tree1d0ea7337861703f4990ccaa0a56b0fd7d017008 /45.md
parent4d8d66d6513a4270dd5d775c139b8e94885426ca (diff)
feat: support counting by filters
Diffstat (limited to '45.md')
-rw-r--r--45.md18
1 files changed, 13 insertions, 5 deletions
diff --git a/45.md b/45.md
index 28e5e96..87e8000 100644
--- a/45.md
+++ b/45.md
@@ -14,18 +14,26 @@ Some queries a client may want to execute against connected relays are prohibiti
14 14
15## Filters and return values 15## Filters and return values
16 16
17This NIP defines a verb called `COUNT`, which accepts a subscription id and a filter as specified in [NIP 01](01.md). 17This NIP defines a verb called `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md).
18
19```
20["COUNT", <subscription_id>, <filters JSON>...]
21```
18 22
19Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements. 23Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements.
20 24
25```
26["COUNT", <subscription_id>, {"count": <integer>}]
27```
28
21Examples: 29Examples:
22 30
23``` 31```
24# Followers count 32# Followers count
25["COUNT", "", {kinds: [3], '#p': [<pubkey>]}] 33["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}]
26["COUNT", "", {count: 238}] 34["COUNT", <subscription_id>, {"count": 238}]
27 35
28# Count posts and reactions 36# Count posts and reactions
29["COUNT", "", {kinds: [1, 7], authors: [<pubkey>]}] 37["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}]
30["COUNT", "", {count: 5}] 38["COUNT", <subscription_id>, {"count": 5}]
31``` 39```