Skip to content

Commit

Permalink
feat: support counting by filters
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyTseng authored and Jonathan Staab committed May 13, 2023
1 parent 4b44453 commit 18a9ddd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions 45.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ Some queries a client may want to execute against connected relays are prohibiti

## Filters and return values

This NIP defines a verb called `COUNT`, which accepts a subscription id and a filter as specified in [NIP 01](01.md).
This NIP defines a verb called `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md).

```
["COUNT", <subscription_id>, <filters JSON>...]
```

Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements.

```
["COUNT", <subscription_id>, {"count": <integer>}]
```

Examples:

```
# Followers count
["COUNT", "", {kinds: [3], '#p': [<pubkey>]}]
["COUNT", "", {count: 238}]
["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}]
["COUNT", <subscription_id>, {"count": 238}]
# Count posts and reactions
["COUNT", "", {kinds: [1, 7], authors: [<pubkey>]}]
["COUNT", "", {count: 5}]
["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}]
["COUNT", <subscription_id>, {"count": 5}]
```

0 comments on commit 18a9ddd

Please sign in to comment.