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

# 全投稿数を取得する

> フルアーカイブから、指定した検索クエリに一致する投稿数を取得します。



## OpenAPI

````yaml /ja/openapi.json GET /2/tweets/counts/all
openapi: 3.0.0
info:
  description: X API v2 で利用可能なエンドポイント
  version: '2.157'
  title: X API v2
  termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
  contact:
    name: X Developers
    url: https://developer.x.com/
  license:
    name: X Developer Agreement and Policy
    url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
  - description: X API
    url: https://api.x.com
security: []
tags:
  - name: Account Activity
    description: AAA サブスクリプションの取得および管理用のエンドポイント
    externalDocs:
      description: 詳細はこちら
      url: >-
        https://docs.x.com/x-api/enterprise-gnip-2.0/fundamentals/account-activity
  - name: Bookmarks
    description: ユーザーのブックマークを取得および管理するためのエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/bookmarks
  - name: Compliance
    description: 自社システム内の X データのコンプライアンスを維持するためのエンドポイント
    externalDocs:
      description: 詳細を見る
      url: >-
        https://developer.twitter.com/en/docs/twitter-api/compliance/batch-tweet/introduction
  - name: Connections
    description: ストリーミング接続を扱うエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.x.com/en/docs/x-api/connections
  - name: Direct Messages
    description: ダイレクトメッセージを取得および管理するためのエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/direct-messages
  - name: General
    description: その他の一般的な API 機能向けエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api
  - name: Lists
    description: リストの取得と管理用エンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/lists
  - name: Media
    description: メディア用エンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.x.com
  - name: MediaUpload
    description: メディアアップロード用エンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.x.com
  - name: News
    description: ニュース記事取得用エンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/news
  - name: Spaces
    description: Spaces の取得と管理用エンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/spaces
  - name: Stream
    description: ストリーミングに関連するエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.x.com
  - name: Tweets
    description: ツイートの取得・検索・変更に関連するエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/tweets/lookup
  - name: Users
    description: ユーザーおよびユーザー間の関係を取得・管理するためのエンドポイント
    externalDocs:
      description: 詳細を見る
      url: https://developer.twitter.com/en/docs/twitter-api/users/lookup
paths:
  /2/tweets/counts/all:
    get:
      tags:
        - Tweets
      summary: 全投稿数を取得する
      description: フルアーカイブから、指定した検索クエリに一致する投稿数を取得します。
      operationId: getPostsCountsAll
      parameters:
        - name: query
          in: query
          description: >-
            投稿をマッチさせるための単一のクエリ／ルール／フィルターです。最大クエリ長については https://t.co/rulelength
            を参照してください。
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 4096
            example: (from:TwitterDev OR from:TwitterAPI) has:media -is:retweet
          style: form
        - name: start_time
          in: query
          description: >-
            YYYY-MM-DDTHH:mm:ssZ。投稿が返される最も古い UTC
            タイムスタンプです。タイムスタンプの粒度は秒で、両端を含みます（例: 12:00:01 はその 1 分間の最初の 1 秒を含みます）。
          required: false
          schema:
            type: string
            format: date-time
          style: form
        - name: end_time
          in: query
          description: >-
            YYYY-MM-DDTHH:mm:ssZ。投稿が返される最新の UTC
            タイムスタンプです。タイムスタンプの粒度は秒で、上限側は排他的です（例: 12:00:01 はその 1 分間の最初の 1
            秒を含みません）。
          required: false
          schema:
            type: string
            format: date-time
          style: form
        - name: since_id
          in: query
          description: 指定したIDより大きい（つまり、より新しい）ポストIDを持つ結果のみを返します。
          required: false
          schema:
            $ref: '#/components/schemas/TweetId'
          style: form
        - name: until_id
          in: query
          description: 指定したIDより小さい（つまり、より古い）ポストIDを持つ結果のみを返します。
          required: false
          schema:
            $ref: '#/components/schemas/TweetId'
          style: form
        - name: next_token
          in: query
          description: >-
            このパラメータは、次の「ページ」の結果を取得するために使用します。値には、API
            レスポンスで返されたものをそのまま指定し、変更しないでください。
          required: false
          schema:
            $ref: '#/components/schemas/PaginationToken36'
          style: form
        - name: pagination_token
          in: query
          description: >-
            このパラメーターは、結果の次の「ページ」を取得するために使用します。このパラメーターに指定する値は、API
            が返すレスポンスからそのまま取得して使用する必要があり、改変してはいけません。
          required: false
          schema:
            $ref: '#/components/schemas/PaginationToken36'
          style: form
        - name: granularity
          in: query
          description: 検索結果件数を集計する際の粒度を指定します。
          required: false
          schema:
            type: string
            enum:
              - minute
              - hour
              - day
            default: hour
          style: form
        - $ref: '#/components/parameters/SearchCountFieldsParameter'
      responses:
        '200':
          description: リクエストは成功しました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Get2TweetsCountsAllResponse'
        default:
          description: リクエストは失敗しました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      security:
        - BearerToken: []
      externalDocs:
        url: >-
          https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all
components:
  schemas:
    TweetId:
      type: string
      description: このツイートの一意の識別子。大きな整数を扱えない言語やツールでの問題を避けるため、文字列として返されます。
      pattern: ^[0-9]{1,19}$
      example: '1346889436626259968'
    PaginationToken36:
      type: string
      description: Base36 形式のページネーショントークン。
      minLength: 1
    Get2TweetsCountsAllResponse:
      type: object
      properties:
        data:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/SearchCount'
        errors:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Problem'
        meta:
          type: object
          properties:
            newest_id:
              $ref: '#/components/schemas/NewestId'
            next_token:
              $ref: '#/components/schemas/NextToken'
            oldest_id:
              $ref: '#/components/schemas/OldestId'
            total_tweet_count:
              $ref: '#/components/schemas/Aggregate'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
    Problem:
      type: object
      description: >-
        IETF RFC 7807 (https://tools.ietf.org/html/rfc7807) で定義された HTTP Problem
        Details オブジェクト。
      required:
        - type
        - title
      properties:
        detail:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
      discriminator:
        propertyName: type
        mapping:
          about:blank:
            $ref: '#/components/schemas/GenericProblem'
          https://api.twitter.com/2/problems/client-disconnected:
            $ref: '#/components/schemas/ClientDisconnectedProblem'
          https://api.twitter.com/2/problems/client-forbidden:
            $ref: '#/components/schemas/ClientForbiddenProblem'
          https://api.twitter.com/2/problems/conflict:
            $ref: '#/components/schemas/ConflictProblem'
          https://api.twitter.com/2/problems/disallowed-resource:
            $ref: '#/components/schemas/DisallowedResourceProblem'
          https://api.twitter.com/2/problems/duplicate-rules:
            $ref: '#/components/schemas/DuplicateRuleProblem'
          https://api.twitter.com/2/problems/invalid-request:
            $ref: '#/components/schemas/InvalidRequestProblem'
          https://api.twitter.com/2/problems/invalid-rules:
            $ref: '#/components/schemas/InvalidRuleProblem'
          https://api.twitter.com/2/problems/noncompliant-rules:
            $ref: '#/components/schemas/NonCompliantRulesProblem'
          https://api.twitter.com/2/problems/not-authorized-for-field:
            $ref: '#/components/schemas/FieldUnauthorizedProblem'
          https://api.twitter.com/2/problems/not-authorized-for-resource:
            $ref: '#/components/schemas/ResourceUnauthorizedProblem'
          https://api.twitter.com/2/problems/operational-disconnect:
            $ref: '#/components/schemas/OperationalDisconnectProblem'
          https://api.twitter.com/2/problems/resource-not-found:
            $ref: '#/components/schemas/ResourceNotFoundProblem'
          https://api.twitter.com/2/problems/resource-unavailable:
            $ref: '#/components/schemas/ResourceUnavailableProblem'
          https://api.twitter.com/2/problems/rule-cap:
            $ref: '#/components/schemas/RulesCapProblem'
          https://api.twitter.com/2/problems/streaming-connection:
            $ref: '#/components/schemas/ConnectionExceptionProblem'
          https://api.twitter.com/2/problems/unsupported-authentication:
            $ref: '#/components/schemas/UnsupportedAuthenticationProblem'
          https://api.twitter.com/2/problems/usage-capped:
            $ref: '#/components/schemas/UsageCapExceededProblem'
    SearchCount:
      type: object
      description: 検索カウント結果を表します。
      required:
        - end
        - start
        - tweet_count
      properties:
        end:
          $ref: '#/components/schemas/End'
        start:
          $ref: '#/components/schemas/Start'
        tweet_count:
          $ref: '#/components/schemas/TweetCount'
    NewestId:
      type: string
      description: このレスポンス内で最も新しい id です。
    NextToken:
      type: string
      description: 次のトークン。
      minLength: 1
    OldestId:
      type: string
      description: このレスポンスに含まれる中で最も古い id。
    Aggregate:
      type: integer
      description: このレスポンスで返された結果の合計。
      format: int32
    GenericProblem:
      description: HTTP ステータスコードで提供される情報以外の追加情報を持たない汎用的な Problem です。
      allOf:
        - $ref: '#/components/schemas/Problem'
    ClientDisconnectedProblem:
      description: クライアントとの接続が切断されました。
      allOf:
        - $ref: '#/components/schemas/Problem'
    ClientForbiddenProblem:
      description: このクライアントがこのリクエストを実行することを禁止されていることを示すProblemです。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            reason:
              type: string
              enum:
                - official-client-forbidden
                - client-not-enrolled
            registration_url:
              type: string
              format: uri
    ConflictProblem:
      description: すでに進行中のジョブがある場合は、新しいジョブを作成できません。
      allOf:
        - $ref: '#/components/schemas/Problem'
    DisallowedResourceProblem:
      description: 要求されたリソースがこの API の原則に違反していることを示す Problem。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          required:
            - resource_id
            - resource_type
            - section
          properties:
            resource_id:
              type: string
            resource_type:
              type: string
              enum:
                - user
                - tweet
                - media
                - list
                - space
            section:
              type: string
              enum:
                - data
                - includes
    DuplicateRuleProblem:
      description: 送信したルールが重複しています。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            id:
              type: string
            value:
              type: string
    InvalidRequestProblem:
      description: このリクエストが無効であることを示す Problem。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            errors:
              type: array
              minItems: 1
              items:
                type: object
                properties:
                  message:
                    type: string
                  parameters:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    InvalidRuleProblem:
      description: 送信されたルールは無効です。
      allOf:
        - $ref: '#/components/schemas/Problem'
    NonCompliantRulesProblem:
      description: ユーザーのルールセットが仕様に準拠していないことを示す Problem。
      allOf:
        - $ref: '#/components/schemas/Problem'
    FieldUnauthorizedProblem:
      description: 特定のツイートやユーザーなどのフィールドを閲覧する権限がないことを示す Problem です。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          required:
            - resource_type
            - field
            - section
          properties:
            field:
              type: string
            resource_type:
              type: string
              enum:
                - user
                - tweet
                - media
                - list
                - space
            section:
              type: string
              enum:
                - data
                - includes
    ResourceUnauthorizedProblem:
      description: 特定のツイートやユーザーなどを閲覧する権限がないことを示す問題です。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          required:
            - value
            - resource_id
            - resource_type
            - section
            - parameter
          properties:
            parameter:
              type: string
            resource_id:
              type: string
            resource_type:
              type: string
              enum:
                - user
                - tweet
                - media
                - list
                - space
            section:
              type: string
              enum:
                - data
                - includes
            value:
              type: string
    OperationalDisconnectProblem:
      description: 運用上の理由により接続が切断されました。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            disconnect_type:
              type: string
              enum:
                - OperationalDisconnect
                - UpstreamOperationalDisconnect
                - ForceDisconnect
                - UpstreamUncleanDisconnect
                - SlowReader
                - InternalError
                - ClientApplicationStateDegraded
                - InvalidRules
    ResourceNotFoundProblem:
      description: 指定されたツイートやユーザーなどが存在しないことを示す Problem です。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          required:
            - parameter
            - value
            - resource_id
            - resource_type
          properties:
            parameter:
              type: string
              minLength: 1
            resource_id:
              type: string
            resource_type:
              type: string
              enum:
                - user
                - tweet
                - media
                - list
                - space
            value:
              type: string
              description: 値はそのフィールドのスキーマに準拠します。
    ResourceUnavailableProblem:
      description: 特定のツイートやユーザーなどがあなたからは利用できない状態であることを示す問題です。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          required:
            - parameter
            - resource_id
            - resource_type
          properties:
            parameter:
              type: string
              minLength: 1
            resource_id:
              type: string
            resource_type:
              type: string
              enum:
                - user
                - tweet
                - media
                - list
                - space
    RulesCapProblem:
      description: ルール数の上限を超えました。
      allOf:
        - $ref: '#/components/schemas/Problem'
    ConnectionExceptionProblem:
      description: 接続に問題が発生していることを示す Problem。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            connection_issue:
              type: string
              enum:
                - TooManyConnections
                - ProvisioningSubscription
                - RuleConfigurationIssue
                - RulesInvalidIssue
    UnsupportedAuthenticationProblem:
      description: 使用されている認証方式がサポートされていないことを示す Problem オブジェクト。
      allOf:
        - $ref: '#/components/schemas/Problem'
    UsageCapExceededProblem:
      description: 使用量の上限を超過したことを示す Problem オブジェクト。
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            period:
              type: string
              enum:
                - Daily
                - Monthly
            scope:
              type: string
              enum:
                - Account
                - Product
    End:
      type: string
      description: バケットの終了時刻。
      format: date-time
    Start:
      type: string
      description: バケットの開始時刻。
      format: date-time
    TweetCount:
      type: integer
      description: バケット内の件数。
  parameters:
    SearchCountFieldsParameter:
      name: search_count.fields
      in: query
      description: レスポンスに含める SearchCount フィールドのカンマ区切りのリスト。
      required: false
      schema:
        type: array
        description: SearchCount オブジェクトで利用可能なフィールド。
        minItems: 1
        uniqueItems: true
        items:
          type: string
          enum:
            - end
            - start
            - tweet_count
        example:
          - end
          - start
          - tweet_count
      explode: false
      style: form
  securitySchemes:
    BearerToken:
      type: http
      scheme: bearer

````