diff options
| -rw-r--r-- | 45.md | 18 |
1 files changed, 13 insertions, 5 deletions
| @@ -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 | ||
| 17 | This NIP defines a verb called `COUNT`, which accepts a subscription id and a filter as specified in [NIP 01](01.md). | 17 | This 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 | ||
| 19 | Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements. | 23 | Counts 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 | |||
| 21 | Examples: | 29 | Examples: |
| 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 | ``` |