X/Twitter API ドキュメント

X/Twitter API: 検索 — 検索クエリによる投稿

ユーザーのクエリをもとに X/Twitter の 検索 データを見つけ、その結果を検索、カタログ、調査の画面に接続します。

オブジェクトの正確な ID がわからず、まず関連する候補を見つける必要がある場合に「検索クエリによる投稿」を使用します。

メソッド GET
エンティティ 検索
バージョン 2
このエンドポイントの機能

この API メソッドで構築できるもの

まず結果と一般的なワークフローを確認し、次にパラメーターと動作するリクエスト例に進んでください。

このエンドポイントが役立つこと

レスポンスには、一致する 検索、公開されているコンテキスト、さらに結果がある場合のページネーションデータが含まれます。

使用に適した場面

オブジェクトの正確な ID がわからず、まず関連する候補を見つける必要がある場合に「検索クエリによる投稿」を使用します。

主なユースケース

製品内の検索

顧客向けおよび社内の画面に、X/Twitter のデータ検索を追加します。

カタログの構築

クエリで候補を見つけ、関連するオブジェクトを保存して後でエンリッチします。

市場調査

トピック、クリエイター、競合の分析のために結果セットを収集します。

利用できるバージョン

レスポンスのバージョン

どちらのバージョンも同じタスクを解決し、同じパラメーターを受け付けます。切り替えを使ってレスポンス構造を比較し、クライアントが想定するバージョンを選んでください。

レスポンスのバージョン V2

このページでバージョンを切り替えると、同じドキュメント URL でレスポンス構造を比較できます。

共通する点

認証、必須パラメーター、リクエストの形は V1 と V2 で同じです。実際には、エンドポイントのパスを組み立てるときとレスポンスを読み取るときにバージョンを選びます。

バージョン間で異なる点

主な違いはレスポンスのエンベロープです。新しい連携では V2 を使用し、既存のクライアント契約との互換性が必要な場合にのみ V1 を残してください。

使い方

メソッドの呼び出し方

どちらのバージョンでも、同じ API キーのヘッダーと同じクエリパラメーターを使用します。このドキュメントでは、まず共通のパラメーターを示し、次に各バージョンのパスとコードスニペットを示します。

入力パラメーター

共通パラメーター
パラメーター 必須 型 例 説明
query はい str technology ユーザーが入力した検索クエリ。
all_of_these_words いいえ str | None AI robotics Optional words that must all appear in matching Twitter/X posts. Example: AI robotics.
any_of_these_words いいえ str | None launch release Optional words where any one may appear in matching Twitter/X posts. Example: launch release.
cursor いいえ str | None DAABCgABF4ABCD... 前のレスポンスで返された次のページのカーソル。最初のページでは省略します。
exact_phrase いいえ str | None machine learning Optional exact phrase that must appear in matching Twitter/X posts. Example: machine learning.
from_accounts いいえ str | None technews xai Optional source accounts without or with @, separated by spaces or commas. Example: technews xai.
hashtags いいえ str | None #TechNews #AI Optional hashtags to require, separated by spaces or commas. Example: #TechNews #AI.
language いいえ str | None en Optional Twitter/X language code. Use 'any' to omit language filtering. Example: en.
link_filter いいえ include | only | exclude | None only Optional link filter: include all posts, only posts with links, or exclude links. Example: only.
mentioning_accounts いいえ str | None technews elonmusk Optional mentioned accounts without or with @, separated by spaces or commas. Example: technews elonmusk.
min_likes いいえ int | None 100 Optional minimum like count. Example: 100.
min_replies いいえ int | None 10 Optional minimum reply count. Example: 10.
min_retweets いいえ int | None 25 Optional minimum repost/retweet count. Example: 25.
none_of_these_words いいえ str | None rumor leak Optional words to exclude from matching Twitter/X posts. Example: rumor leak.
reply_filter いいえ include | only | exclude | None exclude Optional reply filter: include all posts, only replies, or exclude replies. Example: exclude.
since_date いいえ date | None 2026-01-01 Optional earliest post date in ISO YYYY-MM-DD format. Example: 2026-01-01.
tag いいえ Top | Latest | People | Photos | Videos | None Latest Optional Twitter/X search product filter. Example: Latest.
to_accounts いいえ str | None technews Optional reply target accounts without or with @, separated by spaces or commas. Example: technews.
until_date いいえ date | None 2026-01-31 Optional latest post date in ISO YYYY-MM-DD format. Example: 2026-01-31.

バージョン別のリクエストパス

V2

エンドポイントの正確なパス、URL の例、コードスニペットをコピーするときにバージョンを選んでください。上のパラメーター一覧は変わりません。

GET /api/v2/twitter.com/search/tweets-by-query

正規化された形式

コード例

curl --request GET \
  --url "https://www.scrapestorm.net/api/v2/twitter.com/search/tweets-by-query" \
  --header "X-API-Key: 00000000-0000-4000-8000-000000000000" \
  --get --data-urlencode 'query=technology' \
  # Optional parameters:
  # --data-urlencode 'all_of_these_words=AI robotics'
  # --data-urlencode 'any_of_these_words=launch release'
  # --data-urlencode 'cursor=DAABCgABF4ABCD...'
  # --data-urlencode 'exact_phrase=machine learning'
  # --data-urlencode 'from_accounts=technews xai'
  # --data-urlencode 'hashtags=#TechNews #AI'
  # --data-urlencode 'language=en'
  # --data-urlencode 'link_filter=only'
  # --data-urlencode 'mentioning_accounts=technews elonmusk'
  # --data-urlencode 'min_likes=100'
  # --data-urlencode 'min_replies=10'
  # --data-urlencode 'min_retweets=25'
  # --data-urlencode 'none_of_these_words=rumor leak'
  # --data-urlencode 'reply_filter=exclude'
  # --data-urlencode 'since_date=2026-01-01'
  # --data-urlencode 'tag=Latest'
  # --data-urlencode 'to_accounts=technews'
  # --data-urlencode 'until_date=2026-01-31'
レスポンス例

バージョン別のライブレスポンス

プレビューには主要なフィールドとコレクションの最初の要素が含まれているため、レスポンスの形をすばやく確認できます。バージョンを切り替えると JSON の形式が変わります。

レスポンス例

V2 レスポンスの JSON

検証済みの例

このコンパクトな JSON の例は、V2 の直近の成功した検証実行から取得したものです。

{
  "success": true,
  "status": "ok",
  "pagination": {
    "cursor": "QVFB...",
    "has_more": true
  },
  "search_context": {
    "query": "Python code",
    "tag": "Top"
  },
  "data": {
    "tweets": {
      "count": 20,
      "items": [
        {
          "url": "https://x.com/freeCodeCamp/status/2078389573567050090",
          "tweet_id": "2078389573567050090",
          "text": "Learning to code can feel overwhelming when you don't know where to start.\n\nSo here's a course for you: Sunny teaches you Python from the ground up.\n\nYou'll install Python, writ…",
          "hashtags": [],
          "emails": [],
          "created_at": "2026-07-18T08:01:03Z",
          "language": "en",
          "source": "Buffer",
          "author": {
            "url": "https://x.com/freeCodeCamp",
            "user_id": "1668100142",
            "username": "freeCodeCamp",
            "display_name": "freeCodeCamp.org",
            "description": "We're a community of millions of people who are building new skills and getting new jobs together. A 501(c)(3) public charity. Tweets by @abbeyrenn.",
            "emails": [],
            "external_links": [],
            "location": "Just here on Earth... for now",
            "created_at": "2013-08-13T15:27:51Z",
            "is_verified": false,
            "is_blue_verified": true,
            "is_protected": false,
            "possibly_sensitive": false,
            "default_profile": false,
            "default_profile_image": false,
            "followers_count": 1204998,
            "following_count": 159,
            "tweet_count": 36772,
            "media_count": 5153,
            "listed_count": 6833,
            "like_count": 72305,
            "professional_type": null,
            "professional_category_name": null,
            "affiliated_account": null,
            "_more_fields": "5 more fields"
          },
          "is_from_automated_account": null,
          "media": {
            "images": [
              "…"
            ],
            "videos": [],
            "gifs": []
          },
          "external_links": [],
          "user_mentions": [],
          "is_reply": false,
          "reply": null,
          "is_quote": false,
          "quote_tweet_id": null,
          "is_retweet": false,
          "retweeted_tweet_id": null,
          "reply_count": 4,
          "retweet_count": 108,
          "quote_count": 3,
          "like_count": 599,
          "bookmark_count": 455,
          "_more_fields": "2 more fields"
        },
        {
          "url": "https://x.com/PythonPr/status/2078910492068786514",
          "tweet_id": "2078910492068786514",
          "text": "Pyramids in Python Code Examples for Beginners ⭐ https://t.co/QngwbiMVkb",
          "hashtags": [],
          "emails": [],
          "created_at": "2026-07-19T18:31:00Z",
          "language": "en",
          "source": "Twitter Web App",
          "author": {
            "url": "https://x.com/PythonPr",
            "user_id": "855384627975831553",
            "username": "PythonPr",
            "display_name": "Python Programming",
            "description": "#python #programming",
            "emails": [],
            "external_links": [],
            "location": "United States",
            "created_at": "2017-04-21T11:36:02Z",
            "is_verified": false,
            "is_blue_verified": true,
            "is_protected": false,
            "possibly_sensitive": false,
            "default_profile": true,
            "default_profile_image": false,
            "followers_count": 208924,
            "following_count": 1162,
            "tweet_count": 9883,
            "media_count": 4108,
            "listed_count": 1243,
            "like_count": 20597,
            "professional_type": null,
            "professional_category_name": null,
            "affiliated_account": null,
            "_more_fields": "5 more fields"
          },
          "is_from_automated_account": null,
          "media": {
            "images": [
              "…"
            ],
            "videos": [],
            "gifs": []
          },
          "external_links": [],
          "user_mentions": [],
          "is_reply": false,
          "reply": null,
          "is_quote": false,
          "quote_tweet_id": null,
          "is_retweet": false,
          "retweeted_tweet_id": null,
          "reply_count": 3,
          "retweet_count": 8,
          "quote_count": 0,
          "like_count": 62,
          "bookmark_count": 39,
          "_more_fields": "2 more fields"
        },
        {
          "_more_items": 18
        }
      ]
    }
  }
}
次のステップ

評価を続ける

このドキュメントを最初の判断材料とし、継続的な利用のためにエンドポイントを接続する前に、料金、プラットフォームのカバー範囲、連携ルールを確認してください。

X/Twitter のプラットフォームページを開く

実装の前に、関連するエンティティ、API メソッドのグループ、関連ドキュメントを比較してください。

プラットフォームページを開く

API メソッドの料金を比較する

利用を拡大する前に、公開料金表でこのメソッドの位置付けを確認してください。

料金を見る

連携ルールを確認する

入門ドキュメントで、認証、バージョン、再試行、テストと本番の違いを確認してください。

ドキュメントを開く
よくある質問

チームが実装前に尋ねる質問

これらの回答を参考に、この API メソッドがワークフロー、バージョンの選択、導入計画に合うかどうかを判断してください。

この X/Twitter API メソッドはどのようなデータを返しますか?

このメソッドは 検索 に対して「検索クエリによる投稿」を実行します。以下のコンパクトなレスポンス例で、フィールドの正確な構造を確認できます。

V1 と V2 のどちらを選ぶべきですか?

新しい連携では、正規化された構造を提供する V2 を選んでください。V1 は、既にプラットフォーム固有の形式を処理しているクライアントとの互換性のためにのみ使用してください。

最初のリクエストには何が必要ですか?

API キーを作成し、リクエストヘッダーで送信し、表の必須パラメーターを指定してください。コード例には、正しいパスとリクエスト構造が既に含まれています。