> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-25dbe28e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Post Counts

> The Post counts endpoints return the volume of Posts matching a query over time, without returning. Reference for the X API v2 standard tier covering counts.

export const Button = ({href, children}) => {
  return <div className="not-prose">
    <a href={href}>
      <button className="x-btn">
        <span>{children}</span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

The Post counts endpoints return the volume of Posts matching a query over time, without returning the Posts themselves. Use these endpoints to analyze trends, understand conversation size, and refine queries before searching.

## Overview

<CardGroup cols={2}>
  <Card title="Volume analysis" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/U2tZKNvxIHRdJDhn/icons/xds/icon-bar-chart.svg?fit=max&auto=format&n=U2tZKNvxIHRdJDhn&q=85&s=8a18e1be94dbb2e2e78c027341a58663" width="24" height="24" data-path="icons/xds/icon-bar-chart.svg">
    Build trendlines and visualizations showing Post volume over time
  </Card>

  <Card title="Query refinement" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/e3R1xX2UTZQ9Duem/icons/xds/icon-filter.svg?fit=max&auto=format&n=e3R1xX2UTZQ9Duem&q=85&s=1e301f93aec3b14cd6ce3867d1eb09d2" width="24" height="24" data-path="icons/xds/icon-filter.svg">
    Estimate result size before running full search queries
  </Card>

  <Card title="Event detection" icon="calendar">
    Identify when conversations peaked around events
  </Card>

  <Card title="Efficient research" icon="gauge-high">
    Understand conversation scale without retrieving all Posts
  </Card>
</CardGroup>

***

## Endpoints

| Endpoint                                                                | Description                       | Access                  |
| :---------------------------------------------------------------------- | :-------------------------------- | :---------------------- |
| GET [`/2/tweets/counts/recent`](/x-api/posts/get-count-of-recent-posts) | Count Posts from last 7 days      | All developers          |
| GET [`/2/tweets/counts/all`](/x-api/posts/get-count-of-all-posts)       | Count Posts from complete archive | Pay-per-use, Enterprise |

***

## Granularity options

Specify how counts are grouped using the `granularity` parameter:

| Granularity | Description               | Use case             |
| :---------- | :------------------------ | :------------------- |
| `minute`    | Counts per minute         | Real-time monitoring |
| `hour`      | Counts per hour (default) | Daily analysis       |
| `day`       | Counts per day            | Long-term trends     |

***

## Recent counts

Count Posts from the **last 7 days**. Available to all developers.

### Features

* Counts grouped by minute, hour, or day
* Same query operators as recent search
* 512-character query length

### Example response

```json theme={null}
{
  "data": [
    { "start": "2024-01-15T00:00:00.000Z", "end": "2024-01-15T01:00:00.000Z", "tweet_count": 1523 },
    { "start": "2024-01-15T01:00:00.000Z", "end": "2024-01-15T02:00:00.000Z", "tweet_count": 1247 },
    { "start": "2024-01-15T02:00:00.000Z", "end": "2024-01-15T03:00:00.000Z", "tweet_count": 892 }
  ],
  "meta": {
    "total_tweet_count": 3662
  }
}
```

<CardGroup cols={2}>
  <Card title="Quickstart" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/PQT1Q9oPgcY8083h/icons/xds/icon-rocket.svg?fit=max&auto=format&n=PQT1Q9oPgcY8083h&q=85&s=3e5f493e95fcef2e842fef96b457ad12" href="/x-api/posts/counts/quickstart/recent-tweet-counts" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    Make your first recent counts request
  </Card>

  <Card title="API Reference" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/z_lSVl09POlSayp3/icons/xds/icon-code.svg?fit=max&auto=format&n=z_lSVl09POlSayp3&q=85&s=82723f7044b7c129de0c9863e817c3c7" href="/x-api/posts/get-count-of-recent-posts" width="24" height="24" data-path="icons/xds/icon-code.svg">
    Full endpoint documentation
  </Card>
</CardGroup>

***

## Full-archive counts

Count Posts from the **complete archive** back to 2006.

<Note>
  Full-archive counts are available to pay-per-use and Enterprise customers.
</Note>

### Features

* Count historical Posts from any time period
* All query operators available
* 1,024-character query length (4,096 for Enterprise)

### Pagination

Results paginate at 31 days per response:

* **Day granularity**: 31 days per page
* **Hour granularity**: 744 hours (31 days) per page
* **Minute granularity**: 44,640 minutes (31 days) per page

<CardGroup cols={2}>
  <Card title="Quickstart" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/PQT1Q9oPgcY8083h/icons/xds/icon-rocket.svg?fit=max&auto=format&n=PQT1Q9oPgcY8083h&q=85&s=3e5f493e95fcef2e842fef96b457ad12" href="/x-api/posts/counts/quickstart/full-archive-tweet-counts" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    Make your first full-archive counts request
  </Card>

  <Card title="API Reference" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/z_lSVl09POlSayp3/icons/xds/icon-code.svg?fit=max&auto=format&n=z_lSVl09POlSayp3&q=85&s=82723f7044b7c129de0c9863e817c3c7" href="/x-api/posts/get-count-of-all-posts" width="24" height="24" data-path="icons/xds/icon-code.svg">
    Full endpoint documentation
  </Card>
</CardGroup>

***

## Query operators

Post counts use the same query syntax as search endpoints:

```
python lang:en -is:retweet
```

<Card title="Build a query" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/taS2E59h6MDn-F3n/icons/xds/icon-search.svg?fit=max&auto=format&n=taS2E59h6MDn-F3n&q=85&s=ffcb0935beb8f1069a972caada55a348" href="/x-api/posts/counts/integrate/build-a-query" width="24" height="24" data-path="icons/xds/icon-search.svg">
  Learn query syntax and operators
</Card>

***

## Important notes

<Note>
  **Counts vs search results**

  Counts may not exactly match search results. Search endpoints apply additional compliance filtering that counts endpoints do not perform.
</Note>

***

## Getting started

<Note>
  **Prerequisites**

  * An approved [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * A [Project and App](/resources/fundamentals/developer-apps) in the Developer Console
  * Your App's [Bearer Token](/resources/fundamentals/authentication)
</Note>

<CardGroup cols={2}>
  <Card title="Recent counts quickstart" icon="clock" href="/x-api/posts/counts/quickstart/recent-tweet-counts">
    Count Posts from the last 7 days
  </Card>

  <Card title="Full-archive quickstart" icon="vault" href="/x-api/posts/counts/quickstart/full-archive-tweet-counts">
    Count historical Posts
  </Card>

  <Card title="Integration guide" icon="https://mintcdn.com/x-preview-mintlify-25dbe28e/U2tZKNvxIHRdJDhn/icons/xds/icon-book.svg?fit=max&auto=format&n=U2tZKNvxIHRdJDhn&q=85&s=0ea9d40074fbf5e1e48ad64f71be89d9" href="/x-api/posts/counts/integrate/overview" width="24" height="24" data-path="icons/xds/icon-book.svg">
    Key concepts and best practices
  </Card>

  <Card title="Sample code" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    Working code examples
  </Card>
</CardGroup>
