Compare commits

...

2 Commits

Author SHA1 Message Date
Bastiaan Quast b4622b11f6
Merge 40e832d012 into 74681c3c14 2025-10-09 08:29:52 +09:00
Vitor Pamplona 74681c3c14
NIP-45 is not a subscription. Changing to query id to reduce confusion. (#2083) 2025-10-08 17:43:37 -05:00
1 changed files with 11 additions and 11 deletions

22
45.md
View File

@ -14,17 +14,17 @@ Some queries a client may want to execute against connected relays are prohibiti
## Filters and return values ## Filters and return values
This NIP defines the verb `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md) for the verb `REQ`. Multiple filters are OR'd together and aggregated into a single count result. This NIP defines the verb `COUNT`, which accepts a query id and filters as specified in [NIP 01](01.md) for the verb `REQ`. Multiple filters are OR'd together and aggregated into a single count result.
``` ```
["COUNT", <subscription_id>, <filters JSON>...] ["COUNT", <query_id>, <filters JSON>...]
``` ```
Counts are returned using a `COUNT` response in the form `{"count": <integer>}`. Relays may use probabilistic counts to reduce compute requirements. Counts are returned using a `COUNT` response in the form `{"count": <integer>}`. Relays may use probabilistic counts to reduce compute requirements.
In case a relay uses probabilistic counts, it MAY indicate it in the response with `approximate` key i.e. `{"count": <integer>, "approximate": <true|false>}`. In case a relay uses probabilistic counts, it MAY indicate it in the response with `approximate` key i.e. `{"count": <integer>, "approximate": <true|false>}`.
``` ```
["COUNT", <subscription_id>, {"count": <integer>}] ["COUNT", <query_id>, {"count": <integer>}]
``` ```
Whenever the relay decides to refuse to fulfill the `COUNT` request, it MUST return a `CLOSED` message. Whenever the relay decides to refuse to fulfill the `COUNT` request, it MUST return a `CLOSED` message.
@ -34,27 +34,27 @@ Whenever the relay decides to refuse to fulfill the `COUNT` request, it MUST ret
### Followers count ### Followers count
``` ```
["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}] ["COUNT", <query_id>, {"kinds": [3], "#p": [<pubkey>]}]
["COUNT", <subscription_id>, {"count": 238}] ["COUNT", <query_id>, {"count": 238}]
``` ```
### Count posts and reactions ### Count posts and reactions
``` ```
["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}] ["COUNT", <query_id>, {"kinds": [1, 7], "authors": [<pubkey>]}]
["COUNT", <subscription_id>, {"count": 5}] ["COUNT", <query_id>, {"count": 5}]
``` ```
### Count posts approximately ### Count posts approximately
``` ```
["COUNT", <subscription_id>, {"kinds": [1]}] ["COUNT", <query_id>, {"kinds": [1]}]
["COUNT", <subscription_id>, {"count": 93412452, "approximate": true}] ["COUNT", <query_id>, {"count": 93412452, "approximate": true}]
``` ```
### Relay refuses to count ### Relay refuses to count
``` ```
["COUNT", <subscription_id>, {"kinds": [4], "authors": [<pubkey>], "#p": [<pubkey>]}] ["COUNT", <query_id>, {"kinds": [1059], "#p": [<pubkey>]}]
["CLOSED", <subscription_id>, "auth-required: cannot count other people's DMs"] ["CLOSED", <query_id>, "auth-required: cannot count other people's DMs"]
``` ```