---
type: api
title: Get a document count
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-cat-count
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-cat-count
products:
  - Elasticsearch
---

# Get a document count


Availability:

## Paths

- `GET` `/_cat/count/{index}`
- `GET` `/_cat/count`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `index` (union IndexName | [] IndexName) — optional, leave it out to use `/_cat/count`
  A comma-separated list of data streams, indices, and aliases used to limit the request.
It supports wildcards (`*`).
To target all data streams and indices, omit this parameter or use `*` or `_all`.

## Description

Get quick access to a document count for a data stream, an index, or an entire cluster.
The document count only includes live documents, not deleted documents which have not yet been removed by the merge process.

IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console.
They are not intended for use by applications. For application consumption, use the count API.

## Required authorization

* Index privileges: `read`

## Query String Parameters

- `h` (union CatCountColumns)
  A comma-separated list of columns names to display. It supports simple wildcards.

Supported values include:
  - `epoch` (or `t`, `time`): The Unix epoch time in seconds since 1970-01-01 00:00:00.
  - `timestamp` (or `ts`, `hms`, `hhmmss`): The current time in HH:MM:SS format.
  - `count` (or `dc`, `docs.count`, `docsCount`): The document count in the cluster or index.
  Values: `epoch`, `t`, `time`, `timestamp`, `ts`, `hms`, `hhmmss`, `count`, `dc`, `docs.count`, `docsCount`
- `s` (union Names)
  List of columns that determine how the table should be sorted.
Sorting defaults to ascending and can be changed by setting `:asc`
or `:desc` as a suffix to the column name.
  One of: `Name` or `Name[]`

## Response

`application/json`

Type: `[] CountRecord`

- `epoch` (StringifiedEpochTimeUnitSeconds)
  seconds since 1970-01-01 00:00:00
- `timestamp` (string TimeOfDay)
  time in HH:MM:SS
- `count` (string)
  the document count
## Code Examples

#### Console

```console
GET /_cat/count/my-index-000001?v=true&format=json
```

#### JavaScript

```javascript
const response = await client.cat.count({
  index: "my-index-000001",
  v: "true",
  format: "json",
});
```

#### Python

```python
resp = client.cat.count(
    index="my-index-000001",
    v=True,
    format="json",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_cat/count/my-index-000001?v=true&format=json" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.cat().count();
```

#### PHP

```php
$resp = $client->cat()->count([
    "index" => "my-index-000001",
    "v" => "true",
    "format" => "json",
]);
```

#### Ruby

```ruby
response = client.cat.count(
  index: "my-index-000001",
  v: "true",
  format: "json"
)
```

## Response Examples

#### Single data stream or index count

A successful response from `GET /_cat/count/my-index-000001?v=true&format=json`. It retrieves the document count for the `my-index-000001` data stream or index.

```json
[
  {
    "epoch": "1475868259",
    "timestamp": "15:24:20",
    "count": "120"
  }
]
```

#### All data streams and indices count

A successful response from `GET /_cat/count?v=true&format=json`. It retrieves the document count for all data streams and indices in the cluster.

```json
[
  {
    "epoch": "1475868259",
    "timestamp": "15:24:20",
    "count": "121"
  }
]
```

