~ / endpoints / Search API

Twitter / X Search Scraper API

Our Twitter search scraper takes a keyword, hashtag, or query and a search tab, then returns the tweets X embeds for that query as structured JSON: text, author, language, and engagement per result. This endpoint is in beta because X aggressively walls logged-out search, so we return what is available and report clearly when a query comes back empty.

Get a free API keyView endpoints
1,000
free requests / mo
2.6s
median response
JSON
structured output
beta
endpoint status

Quickstart

cURL
curl "https://api.twitterscraperapi.com/api/v1/xtwitter/search?q=nasa&f=top&api_key=$API_KEY"
Python
import requests, os

BASE = "https://api.twitterscraperapi.com"
API_KEY = os.environ["API_KEY"]

# Query plus a search tab: top | live | user | image | video.
resp = requests.get(
    f"{BASE}/api/v1/xtwitter/search",
    params={
        "q": "nasa",
        "f": "top",
        "limit": 20,
        "api_key": API_KEY,
    },
    timeout=30,
)
data = resp.json()

# X walls logged-out search hard, so always check results_count first.
print(data["query"], "->", data["results_count"], "tweets")
for t in data["results"]:
    print(t["position"], t["author"], "-", t["full_text"])

Response

200 OK
{
  "query": "nasa",
  "page": 1,
  "results_count": 1,
  "total_results": 1,
  "results": [
    {
      "position": 1,
      "id": "20",
      "title": "just setting up my twttr",
      "url": "https://x.com/jack/status/20",
      "author": "jack",
      "full_text": "just setting up my twttr",
      "lang": "en",
      "retweet_count": null,
      "favorite_count": 308537,
      "reply_count": 17947,
      "created_at": "2006-03-21T20:50:14.000Z"
    }
  ]
}
FieldTypeDescription
querystringThe query that was searched, echoed back from your q input.
pageintegerThe result page number, currently 1 per request.
results_countintegerNumber of tweets returned in this response. Check this first, since a walled query can return 0.
total_resultsintegerTotal tweets parsed from the page before any limit slice was applied.
resultsarrayThe matched tweets. Each item carries position, id, title, url, author, full_text, lang, created_at, and engagement counts.
results[].authorstringThe screen_name of the tweet's author.
results[].full_textstringThe tweet body. title carries the same text for cross-category consistency.
results[].favorite_countinteger or nullLikes on the tweet when X embeds the figure, otherwise null.

Use it for

>

Keyword and brand monitoring

Search a brand name or phrase on a schedule to catch the tweets X surfaces for it, then route text and author into your alerting.
>

Hashtag tracking

Query a #hashtag to collect the posts X returns for a campaign or event and store text, author, and engagement as JSON.
>

Topic and trend sampling

Pull the top or live tab for a topic to sample what is being said, feeding the text into sentiment or clustering.
>

Media discovery

Use the image or video tab to find tweets carrying media for a query when X embeds them in the search payload.

Pricing

PlanPriceBest for
Free1,000 requestsTesting and small jobs
Pro$0.60 / 1kProduction workloads
Pay-as-you-go$0.90 / 1kSpiky or one-off volume

Median response 2.6s. You only pay for successful requests.

FAQ

What is a Twitter search scraper?

A Twitter search scraper is a tool that runs a keyword, hashtag, or query against X's search and returns the matching tweets in a structured format. Our search endpoint takes a q query and an f tab, fetches X's public search page, parses the tweet objects embedded in its state, and returns them as JSON with text, author, language, and engagement per result.

Why is the search endpoint marked beta?

Because X is one of the most aggressive logged-out walls on the web. A guest request to the search page usually returns a JavaScript shell with a login gate and no tweet data embedded, since results stream in later over X's authenticated API. Our endpoint parses whatever tweets X does embed in the initial page and reports a clear diagnostic when a query comes back empty, so we keep it labelled beta rather than promising a full public search feed.

How do I know if a query returned real results?

Check results_count on the response before reading results. It is the number of tweets we parsed for that query. When X serves only a login shell, results_count is 0 and the response includes a diagnostic noting the page length and which markers were present, so you can tell an empty result apart from a genuine no-match.

Which search tabs are supported?

The f parameter accepts the same tabs X uses on /search: top, live, user, image, and video. It defaults to top. The tab is passed straight through to X, so image and video bias the query toward tweets with media when X embeds them.

Do I need an X developer account or paid API to search?

No. You authenticate with a single twitterscraperapi key. There is no X developer account and no paid X API tier, which for search starts around 100 dollars a month. The free tier includes 1,000 requests. For a reliable single-tweet read, the tweet endpoint is far more consistent than search because it uses X's public syndication payload.

Can I get every tweet for a hashtag?

No tool can guarantee that from logged-out access, and we do not claim to. X only exposes a slice of matching tweets to guests, and often none, so this endpoint returns the tweets embedded in the search page up to your limit rather than a complete historical set. For exhaustive archive search you would need X's paid full-archive API tier.

Get search api as JSON
Free plan, 1,000 requests. No credit card required.
Get a free API key All endpoints