> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Post Counts

> Post counts エンドポイントは、クエリに一致する投稿の時間経過に伴うボリュームを、投稿本文を返さずに提供します。counts を扱う X API v2 スタンダードティアのリファレンス。

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>;
};

Post counts エンドポイントは、クエリに一致する投稿の時間経過に伴うボリュームを、投稿本文を返さずに提供します。これらのエンドポイントを使用して、トレンドを分析したり、会話規模を把握したり、検索を実行する前にクエリを洗練したりできます。

## 概要

<CardGroup cols={2}>
  <Card title="ボリューム分析" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-bar-chart.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=e2a41caa858b122416f0005a55a8f143" width="24" height="24" data-path="icons/xds/icon-bar-chart.svg">
    投稿ボリュームの時間推移を示すトレンドラインや可視化を構築
  </Card>

  <Card title="クエリのリファイン" icon="https://mintcdn.com/x-preview/szd6PKNMlRQoyyAo/icons/xds/icon-filter.svg?fit=max&auto=format&n=szd6PKNMlRQoyyAo&q=85&s=5d59aff402c1f2aeae0e9e44bb23400e" width="24" height="24" data-path="icons/xds/icon-filter.svg">
    完全な検索クエリを実行する前に結果サイズを見積もる
  </Card>

  <Card title="イベント検出" icon="calendar">
    イベント周辺で会話がピークに達した時点を特定
  </Card>

  <Card title="効率的なリサーチ" icon="gauge-high">
    全投稿を取得せずに会話規模を把握
  </Card>
</CardGroup>

***

## エンドポイント

| Endpoint                                                                | Description     | Access          |
| :---------------------------------------------------------------------- | :-------------- | :-------------- |
| GET [`/2/tweets/counts/recent`](/x-api/posts/get-count-of-recent-posts) | 直近 7 日間の投稿数を集計  | すべての開発者         |
| GET [`/2/tweets/counts/all`](/x-api/posts/get-count-of-all-posts)       | 完全アーカイブから投稿数を集計 | 従量課金、Enterprise |

***

## Granularity オプション

`granularity` パラメーターで集計単位を指定します:

| Granularity | Description        | Use case     |
| :---------- | :----------------- | :----------- |
| `minute`    | 1 分ごとのカウント         | リアルタイムモニタリング |
| `hour`      | 1 時間ごとのカウント(デフォルト) | 日次分析         |
| `day`       | 1 日ごとのカウント         | 長期トレンド       |

***

## Recent counts

**直近 7 日間**の投稿数をカウントします。すべての開発者が利用可能です。

### 特徴

* 分・時間・日単位でグループ化されたカウント
* Recent search と同じクエリ演算子
* 512 文字までのクエリ長

### レスポンス例

```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="クイックスタート" icon="https://mintcdn.com/x-preview/oR-aRNyj1BKPJtxM/icons/xds/icon-rocket.svg?fit=max&auto=format&n=oR-aRNyj1BKPJtxM&q=85&s=b978d7a9225de31709efbbed5b84e92d" href="/x-api/posts/counts/quickstart/recent-tweet-counts" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    最初の recent counts リクエストを行う
  </Card>

  <Card title="API リファレンス" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-code.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=488e23401b19225b89acc0136d242219" href="/x-api/posts/get-count-of-recent-posts" width="24" height="24" data-path="icons/xds/icon-code.svg">
    エンドポイントの完全なドキュメント
  </Card>
</CardGroup>

***

## Full-archive counts

2006 年までさかのぼる**完全アーカイブ**から投稿数を集計します。

<Note>
  Full-archive counts は従量課金と Enterprise のお客様が利用できます。
</Note>

### 特徴

* 任意の期間の履歴投稿数を集計
* すべてのクエリ演算子が利用可能
* 1,024 文字までのクエリ長(Enterprise は 4,096 文字)

### ページネーション

レスポンスあたり 31 日でページ分割されます:

* **Day granularity**: 1 ページあたり 31 日
* **Hour granularity**: 1 ページあたり 744 時間 (31 日)
* **Minute granularity**: 1 ページあたり 44,640 分 (31 日)

<CardGroup cols={2}>
  <Card title="クイックスタート" icon="https://mintcdn.com/x-preview/oR-aRNyj1BKPJtxM/icons/xds/icon-rocket.svg?fit=max&auto=format&n=oR-aRNyj1BKPJtxM&q=85&s=b978d7a9225de31709efbbed5b84e92d" href="/x-api/posts/counts/quickstart/full-archive-tweet-counts" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    最初の full-archive counts リクエストを行う
  </Card>

  <Card title="API リファレンス" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-code.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=488e23401b19225b89acc0136d242219" href="/x-api/posts/get-count-of-all-posts" width="24" height="24" data-path="icons/xds/icon-code.svg">
    エンドポイントの完全なドキュメント
  </Card>
</CardGroup>

***

## クエリ演算子

Post counts は search エンドポイントと同じクエリ構文を使用します:

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

<Card title="クエリを組み立てる" icon="https://mintcdn.com/x-preview/cfyQtgCdwk8p69aa/icons/xds/icon-search.svg?fit=max&auto=format&n=cfyQtgCdwk8p69aa&q=85&s=8c11ad89387b7c09ced1553d5c232834" href="/x-api/posts/counts/integrate/build-a-query" width="24" height="24" data-path="icons/xds/icon-search.svg">
  クエリ構文と演算子を学ぶ
</Card>

***

## 重要事項

<Note>
  **Counts と検索結果**

  Counts は検索結果と完全に一致しない場合があります。検索エンドポイントは、counts エンドポイントでは行われない追加のコンプライアンスフィルタリングを適用します。
</Note>

***

## はじめる

<Note>
  **前提条件**

  * 承認済みの[開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * 開発者コンソール内の [Project と App](/resources/fundamentals/developer-apps)
  * App の [Bearer Token](/resources/fundamentals/authentication)
</Note>

<CardGroup cols={2}>
  <Card title="Recent counts クイックスタート" icon="clock" href="/x-api/posts/counts/quickstart/recent-tweet-counts">
    直近 7 日間の投稿数を集計
  </Card>

  <Card title="Full-archive クイックスタート" icon="vault" href="/x-api/posts/counts/quickstart/full-archive-tweet-counts">
    履歴投稿数を集計
  </Card>

  <Card title="統合ガイド" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-book.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=22ac564792481d14ae36a941546039c8" href="/x-api/posts/counts/integrate/overview" width="24" height="24" data-path="icons/xds/icon-book.svg">
    主要な概念とベストプラクティス
  </Card>

  <Card title="サンプルコード" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    動作するコード例
  </Card>
</CardGroup>
