Nostr Event Count

Job request to count matching events

Input

The input MUST be a JSON-encoded list of filters as specified in NIP 01.

Output

content MUST contain a stringified number representing the final count. DVMs MAY return partial results using kind 7000 in the same format.

Params

  • relay: a relay url to include in the count (required, client MAY provide more than one relay)
  • group: an event field or tag name to group results by, resulting in a potentially nested dictionary of results (optional, client MAY provide more than one group). Supported groups include:
    • content - an event’s content field
    • pubkey - an event’s pubkey field
    • reply - an event’s reply e-tag
    • root - an event’s root e-tag
    • Any other value will be assumed to be a tag name. The first matching tag’s value will be used.

How clients can use this

Clients may want to avoid downloading large datasets from many relays simply in order to de-duplicate and count them. This can be useful for a number of things:

  • Counting pubkey followers and other social graph analysis like web of trust score calculation
  • Retrieving counts for list pages (number of messages in a conversation, number of lists on a profile)
  • Getting metadata for tags (this topic has been used x times)

Example

Request

{
    "content": "[{\"#t\":[\"zapathon\"]}]",
    "kind": 5400,
    "tags": []
}

Response

{
    "kind": 6400,
    "content": "129469"
}

Request

{
    "content": "[{\"#kinds\":[7], \"#e\":[\"7b0d90f1973da1cea186c85fbd09b3e4e455ce4d438b60a3d1f9aabc1681418f\"}]",
    "kind": 5400,
    "tags": [
      ["param", "group", "content"]
    ]
}

Response

{
    "kind": 6400,
    "content": "{\"🤙\":224,\"+\":31,\"🧡\":2,\"❤️\":7,\"🤣\":3,\"\":2,\"💜\":7,\":thinking face:\":1,\"🦶\":1,\"🍺\":1,\"🍆\":2,\"🤙🏼\":3,\"🔥\":2,\"🏇\":1,\"💚\":1}"
}