> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-b4f5bfb1.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-b4f5bfb1/E43Ep5Gv29gM6HJ6/icons/xds/icon-bar-chart.svg?fit=max&auto=format&n=E43Ep5Gv29gM6HJ6&q=85&s=d8e59c39f35d2ed23f4351f6d1ee9d21" 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-b4f5bfb1/JQeJOWY1pPelLM8w/icons/xds/icon-filter.svg?fit=max&auto=format&n=JQeJOWY1pPelLM8w&q=85&s=6fcb74f47766174bbd2fd52b6934b028" 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-b4f5bfb1/CJEW78ZoFC_WB4AV/icons/xds/icon-rocket.svg?fit=max&auto=format&n=CJEW78ZoFC_WB4AV&q=85&s=c4d643f2a562a30abeccca3349337f50" 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-b4f5bfb1/NEh9mjpH7RaTDEed/icons/xds/icon-code.svg?fit=max&auto=format&n=NEh9mjpH7RaTDEed&q=85&s=07116236bb3000cffffbf6c9bac6d47e" 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-b4f5bfb1/CJEW78ZoFC_WB4AV/icons/xds/icon-rocket.svg?fit=max&auto=format&n=CJEW78ZoFC_WB4AV&q=85&s=c4d643f2a562a30abeccca3349337f50" 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-b4f5bfb1/NEh9mjpH7RaTDEed/icons/xds/icon-code.svg?fit=max&auto=format&n=NEh9mjpH7RaTDEed&q=85&s=07116236bb3000cffffbf6c9bac6d47e" 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-b4f5bfb1/Y4pnhTTwR7PxYSWw/icons/xds/icon-search.svg?fit=max&auto=format&n=Y4pnhTTwR7PxYSWw&q=85&s=34acaf7217390e86b285fcf3114b1cee" 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-b4f5bfb1/E43Ep5Gv29gM6HJ6/icons/xds/icon-book.svg?fit=max&auto=format&n=E43Ep5Gv29gM6HJ6&q=85&s=58d2163a527af71742b049fc4dc92669" 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>
