Twitter / X · Guide

How to run a Twitter / X search

TL;DR
To run a Twitter / X search, sign up for a free Captapi key, then send one GET request to /v1/twitter/search with your input. You get clean JSON back in seconds for 2 credits per call — no OAuth, scraping or platform SDKs. Search public tweets on X by keyword — text, author, likes, reposts, hashtags, and media for each matching post. Flat 2 credits per call.

How to run a Twitter / X search (step by step)

  1. 1

    Get a free API key

    Create a free Captapi account (100 credits, no card) and generate an API key from the dashboard.

  2. 2

    Call the Twitter/X Search API

    Send an authenticated GET request to /v1/twitter/search with your input. No OAuth, no scraping setup.

  3. 3

    Read the JSON response

    Parse the clean JSON response. Pass cache=true for a free 24h cache hit; default is always fresh.

Code example

curl "https://api.captapi.com/v1/twitter/search?q=nasa" \
  -H "Authorization: Bearer capt_live_..."
# or: -H "x-api-key: capt_live_..."

What the response looks like

{
  "success": true,
  "data": {
    "query": "nasa",
    "totalReturned": 5,
    "results": [
      {
        "platform": "twitter",
        "url": "https://x.com/NASA/status/2040468080686424396",
        "id": "2040468080686424396",
        "text": "This view just hits different 🌍\n \n@Astro_Christina and @astro_reid take a moment to look back at Earth as they continue deep into space toward the Moon. https://t.co/NMDeLj256K",
        "lang": "en",
        "publishedAt": "Sat Apr 04 16:34:35 +0000 2026",
        "author": {
          "username": "NASA",
          "displayName": "NASA",
          "url": "https://x.com/NASA",
          "followers": 92225387,
          "verified": true,
          "profileImage": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg"
        },
        "engagement": {
          "views": 26608930,
          "likes": 196244,
          "replies": 3349,
          "retweets": 29241,
          "quotes": 2911,
          "bookmarks": 11267
        },
        "isReply": false,
        "isRetweet": false,
        "media": [
          "https://pbs.twimg.com/media/HFEy5njWsAArPaK.jpg",
          "https://pbs.twimg.com/media/HFEy56IXwAAnG2M.jpg"
        ]
      },
      {
        "platform": "twitter",
        "url": "https://x.com/NASASolarSystem/status/2081803694480261151",
        "id": "2081803694480261151",
        "text": "On Aug. 12, a total solar eclipse will cross Greenland, Iceland, and Spain — and NASA science will be there! ☀️🌑🔭\n\nWe're flying high-altitude jets and launching scientific balloons to study the Sun and the eclipse's effects on us: https://t.co/zPn8UavJ3m\n\n📸: NASA/Ernie Wright https://t.co/wVJzVGJ3Ao",
        "lang": "en",
        "publishedAt": "Mon Jul 27 18:07:33 +0000 2026",
        "author": {
          "username": "NASASolarSystem",
          "displayName": "NASA Solar System",
          "url": "https://x.com/NASASolarSystem",
          "followers": 2966292,
          "verified": true,
          "profileImage": "https://pbs.twimg.com/profile_images/1852211324224442369/9KHp7JLo_normal.jpg"
        },
        "engagement": {
          "views": 371846,
          "likes": 1674,
          "replies": 62,
          "retweets": 406,
          "quotes": 20,
          "bookmarks": 176
        },
        "isReply": false,
        "isRetweet": false,
        "media": [
          "https://pbs.twimg.com/amplify_video_thumb/2081803656530190336/img/zUx_qij2E2oP-MsL.jpg"
        ]
      },
      {
        "platform": "twitter",
        "url": "https://x.com/NASA/status/2054251010625765655",
        "id": "2054251010625765655",
        "text": "Perseverance in the Wild Martian West 🤠\n\nOur Perseverance Mars rover snapped some photos beyond the western rim of Jezero Crater—the farthest west the rover has ever gone on the Red Planet. See what we found there: https://t.co/nIkwxstE26 https://t.co/6gJ9xgnVy5",
        "lang": "en",
        "publishedAt": "Tue May 12 17:23:01 +0000 2026",
        "author": {
          "username": "NASA",
          "displayName": "NASA",
          "url": "https://x.com/NASA",
          "followers": 92225387,
          "verified": true,
          "profileImage": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg"
        },
        "engagement": {
          "views": 1182851,
          "likes": 20257,
          "replies": 962,
          "retweets": 3777,
          "quotes": 123,
          "bookmarks": 693
        },
        "isReply": false,
        "isRetweet": false,
        "media": [
          "https://pbs.twimg.com/tweet_video_thumb/HIIqYwtWsAAcoyZ.jpg"
        ]
      },
      {
        "platform": "twitter",
        "url": "https://x.com/NASA/status/2082511887757881648",
        "id": "2082511887757881648",
        "text": "There's a solar eclipse happening on Wednesday, Aug. 12 — and if you're not in the path of totality, you can watch along with us online! Get the details: https://t.co/aAYzLGEqPU https://t.co/7yrWQpTkld",
        "lang": "en",
        "publishedAt": "Wed Jul 29 17:01:39 +0000 2026",
        "author": {
          "username": "NASA",
          "displayName": "NASA",
          "url": "https://x.com/NASA",
          "followers": 92225387,
          "verified": true,
          "profileImage": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg"
        },
        "engagement": {
          "views": 93400,
          "likes": 549,
          "replies": 87,
          "retweets": 146,
          "quotes": 13,
          "bookmarks": 61
        },
        "isReply": false,
        "isRetweet": false,
        "media": [
          "https://pbs.twimg.com/media/HOaRhlyWEAA1C8Q.jpg"
        ]
      },
      {
        "platform": "twitter",
        "url": "https://x.com/SpaceNews92/status/2082081188114808938",
        "id": "2082081188114808938",
        "text": "The Saturn V's mighty F-1 engine could only fire once... but SpaceX's Raptor can shut down, restart in space, then restart AGAIN before landing. How did rocket engines evolve that much?\n#spacex #starship #saturnV #nasa https://t.co/dRBxTiL5JA",
        "lang": "en",
        "publishedAt": "Tue Jul 28 12:30:13 +0000 2026",
        "author": {
          "username": "SpaceNews92",
          "displayName": "Rocketry",
          "url": "https://x.com/SpaceNews92",
          "followers": 5245,
          "verified": true,
          "profileImage": "https://pbs.twimg.com/profile_images/1978478483543044096/-hWF_un1_normal.jpg"
        },
        "engagement": {
          "views": 31847,
          "likes": 903,
          "replies": 28,
          "retweets": 72,
          "quotes": 1,
          "bookmarks": 166
        },
        "isReply": false,
        "isRetweet": false,
        "hashtags": [
          "spacex",
          "starship",
          "saturnV",
          "nasa"
        ],
        "media": [
          "https://pbs.twimg.com/amplify_video_thumb/2082079317249724416/img/UdzqLA-kveH5BQdg.jpg"
        ]
      }
    ]
  }
}

Billing metadata (credits charged, cache hit/miss) is returned in the X-Captapi-Credits and X-Captapi-Cache response headers.

Request parameters

NameTypeRequiredDescription
qstring YesKeyword or phrase to search public tweets on X (min 2 characters).
limitintegerNoMax items to return (default 20, max 200). Billed per result.
cachebooleanNoSet true to serve from the 24h response cache. Default false — always fetch fresh data.

Frequently asked questions

What does the Twitter/X Search API do?

The Twitter/X Search API lets you search and return matching results from a public Twitter / X query using one GET request to /v1/twitter/search. It returns clean JSON — no OAuth or infrastructure setup required.

How many credits does the Twitter/X Search API cost?

Each successful call costs 2 credits. Pass cache=true to serve from the 24h shared cache (0 credits on hit); default is always fresh. Failed or empty results are never charged.

Do I need a Twitter / X API key or OAuth?

No. A single Captapi key works across every platform Captapi supports — YouTube, TikTok, Instagram, Facebook, Twitter/X, Reddit, Threads, Bluesky, Pinterest, LinkedIn, Rumble, Spotify, Kwai, and more. We handle proxies, rate limits, retries, and authentication for you.

Is the Twitter/X Search API suitable for production use?

Yes. It is a stable REST endpoint with predictable JSON and automatic retries. Pass cache=true to serve from the 24h shared cache (0 credits on hit); default is always fresh. Use it for analytics, monitoring, and content automation.

Ready to run a Twitter / X search?

Start free with 100 credits — no credit card required.

Get your free API key