# at.spandrel.counts.getRecordCounts

> Get the number of records in each collection of an account's repo.

- Kind: query
- Authority: counts.spandrel.at
- Lexicon: 1
- Published by [spandrel.at](https://lexicon.garden/identity/did:plc:rumwhtwo2qolqody5rn25ze5), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:rumwhtwo2qolqody5rn25ze5/at.spandrel.counts.getRecordCounts)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:rumwhtwo2qolqody5rn25ze5/at.spandrel.counts.getRecordCounts/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:rumwhtwo2qolqody5rn25ze5/at.spandrel.counts.getRecordCounts/analytics)

## Query (`at.spandrel.counts.getRecordCounts`)

Type: query · GET

### Parameters (query string)

- `collection` (array): Which collections to return counts for. If omitted, every collection is returned.
  - Constraints: maxLength: 50
  - `items` (string · nsid)
- `repo` (string · did, required): The account. Only did:plc and did:web are supported.

### Output (application/json)

- `counts` (array, required): One count per collection, sorted by collection name.
  - `items` (ref)
    - Reference: `#collectionCount`
- `did` (string · did, required)
- `rev` (string · tid, required): The last counted repo revision.

### Errors

- `RepoTakendown`: No description in schema.
- `RepoSuspended`: No description in schema.
- `RepoDeactivated`: No description in schema.
- `RepoDeleted`: No description in schema.
- `RepoNotFound`: No repo was found for this account.
- `RepoTooLarge`: The repo is too large to count.
- `UpstreamFailure`: The repo could not be fetched.
- `CountInProgress`: The repo is still being counted. Retry after the time in the Retry-After header.
- `CountQueueFull`: Too many accounts are waiting to be counted. Retry after the time in the Retry-After header.

## #collectionCount (`at.spandrel.counts.getRecordCounts#collectionCount`)

Type: object

### Properties

- `collection` (string · nsid, required)
- `count` (integer, required)
  - Constraints: minimum: 1

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "collectionCount": {
      "properties": {
        "collection": {
          "format": "nsid",
          "type": "string"
        },
        "count": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "collection",
        "count"
      ],
      "type": "object"
    },
    "main": {
      "description": "Get the number of records in each collection of an account's repo.",
      "errors": [
        {
          "name": "RepoTakendown"
        },
        {
          "name": "RepoSuspended"
        },
        {
          "name": "RepoDeactivated"
        },
        {
          "name": "RepoDeleted"
        },
        {
          "description": "No repo was found for this account.",
          "name": "RepoNotFound"
        },
        {
          "description": "The repo is too large to count.",
          "name": "RepoTooLarge"
        },
        {
          "description": "The repo could not be fetched.",
          "name": "UpstreamFailure"
        },
        {
          "description": "The repo is still being counted. Retry after the time in the Retry-After header.",
          "name": "CountInProgress"
        },
        {
          "description": "Too many accounts are waiting to be counted. Retry after the time in the Retry-After header.",
          "name": "CountQueueFull"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "counts": {
              "description": "One count per collection, sorted by collection name.",
              "items": {
                "ref": "#collectionCount",
                "type": "ref"
              },
              "type": "array"
            },
            "did": {
              "format": "did",
              "type": "string"
            },
            "rev": {
              "description": "The last counted repo revision.",
              "format": "tid",
              "type": "string"
            }
          },
          "required": [
            "did",
            "rev",
            "counts"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "collection": {
            "description": "Which collections to return counts for. If omitted, every collection is returned.",
            "items": {
              "format": "nsid",
              "type": "string"
            },
            "maxLength": 50,
            "type": "array"
          },
          "repo": {
            "description": "The account. Only did:plc and did:web are supported.",
            "format": "did",
            "type": "string"
          }
        },
        "required": [
          "repo"
        ],
        "type": "params"
      },
      "type": "query"
    }
  },
  "id": "at.spandrel.counts.getRecordCounts",
  "lexicon": 1
}
```
