# pub.techne.draft.commons.countClusters

> How many clusters listClusters would list, optionally of one collection (a calendar event, a placeV2 or a place; places are curated as placeV2, so a place counts only the curated places published before that move, superseded once their placeV2 is written; any other is InvalidRequest), by merge readiness and by roll-up. Anonymous. Counting reads every cluster, so the commons counts in the background and answers the last count (up to a server-configured interval old); until the first count for a collection lands it answers CountPending.

- Kind: query
- Authority: commons.draft.techne.pub
- Lexicon: 1
- Published by [lexicons.techne.town](https://lexicon.garden/identity/did:plc:cbtfheqpi4g6vlrha4tpoh53), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:cbtfheqpi4g6vlrha4tpoh53/pub.techne.draft.commons.countClusters)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:cbtfheqpi4g6vlrha4tpoh53/pub.techne.draft.commons.countClusters/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:cbtfheqpi4g6vlrha4tpoh53/pub.techne.draft.commons.countClusters/analytics)

## Query (`pub.techne.draft.commons.countClusters`)

Type: query · GET

### Parameters (query string)

- `collection` (string · nsid)

### Output (application/json)

- `byReadiness` (array, required)
  - `items` (ref)
    - Reference: `pub.techne.draft.commons.defs#countGroup`
- `complete` (integer, required): Clusters whose readiness roll-up is complete.
- `count` (integer, required)

### Errors

- `InvalidRequest`: No description in schema.
- `CountPending`: No count for this collection has finished yet; one is running. Ask again in a few minutes.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "How many clusters listClusters would list, optionally of one collection (a calendar event, a placeV2 or a place; places are curated as placeV2, so a place counts only the curated places published before that move, superseded once their placeV2 is written; any other is InvalidRequest), by merge readiness and by roll-up. Anonymous. Counting reads every cluster, so the commons counts in the background and answers the last count (up to a server-configured interval old); until the first count for a collection lands it answers CountPending.",
      "errors": [
        {
          "name": "InvalidRequest"
        },
        {
          "description": "No count for this collection has finished yet; one is running. Ask again in a few minutes.",
          "name": "CountPending"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "byReadiness": {
              "items": {
                "ref": "pub.techne.draft.commons.defs#countGroup",
                "type": "ref"
              },
              "type": "array"
            },
            "complete": {
              "description": "Clusters whose readiness roll-up is complete.",
              "type": "integer"
            },
            "count": {
              "type": "integer"
            }
          },
          "required": [
            "count",
            "byReadiness",
            "complete"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "collection": {
            "format": "nsid",
            "type": "string"
          }
        },
        "type": "params"
      },
      "type": "query"
    }
  },
  "id": "pub.techne.draft.commons.countClusters",
  "lexicon": 1
}
```
