WEIR

Twitter Search API in 2026: X Endpoints, Limits, Cost

The Twitter search API in 2026, from X's own docs: recent and full-archive paths, query limits, next_token paging, counts and prices, with real calls.


Published · Updated · 7 min read

Cover image: Three ways to search X

The Twitter search API is two X endpoints: recent search for the past week, and full-archive search for posts back to 2006.

This guide is for developers who need X (Twitter) posts by keyword, account or date. You get X's limits and prices, first calls, and a shorter route through Weir, which we run.

Your first recent search, with a bearer token:

curl "https://api.x.com/2/tweets/search/recent?query=from%3Agithub%20-is%3Aretweet&tweet.fields=created_at,public_metrics" \
  -H "Authorization: Bearer $X_BEARER_TOKEN"
  1. Pick an endpointRecent for a week, full-archive for older.
  2. Write the queryIn X's v2 operator dialect.
  3. Make the first callOne curl and a bearer token.
  4. Page with next_tokenUntil it's missing.
  5. Count firstOne request sizes a query.
  6. Or use WeirJSON fields, 1 credit per post.

Step 1: Pick a Twitter API search endpoint

X's docs list two search endpoints, as of 22 October 2026:

Feature Recent search Full-archive search
Path GET /2/tweets/search/recent GET /2/tweets/search/all
Reaches back 7 days March 2006
Who can call it All developers Pay-per-use and Enterprise
Posts per request 10 to 100 10 to 500
Query length 512 characters 1,024 characters
Requests per 15 min, app 450 300, and 1 a second

On Enterprise, you get 4,096 characters for both.

Only recent search takes a user token, and private metrics on your own posts need one.

Step 2: Write the query in X's API dialect

You write the query as one string of operators, in a dialect close to x.com's search box but not the same:

  • Words and phrases: python, "open source", (rust OR golang), and -crypto to exclude.
  • Accounts and threads: from:github, to:github, @github, list: and conversation_id:.
  • Post type: is:retweet, is:reply, is:quote, has:media, has:links and lang:en.
  • Engagement: min_likes:, min_reposts: and min_replies:, added on 4 May 2026.

The post-type operators can't stand alone. X calls them conjunction-required, so you must put a word or a from: beside has:media.

Watch the order, too. A space means AND and binds before OR, so apple OR iphone ipad means apple OR (iphone ipad).

Our operator guide maps each x.com operator to its v2 name.

Step 3: Make your first call to each endpoint

The recent search call is at the top of this page, and our guide to getting an X API key shows how to get its token. For full-archive search, you add dates in ISO 8601:

curl "https://api.x.com/2/tweets/search/all?query=from%3Agithub&start_time=2020-01-01T00%3A00%3A00Z&end_time=2021-01-01T00%3A00%3A00Z&max_results=100" \
  -H "Authorization: Bearer $X_BEARER_TOKEN"

What we ran, and what we didn't. We have no X API key here. On 22 October 2026 we sent both searches and both counts calls without a token, and X answered each the same way:

{ "title": "Unauthorized", "type": "about:blank", "status": 401, "detail": "Unauthorized" }

So the X details here come from X's docs.

A bare request gives you only id, text and edit_history_tweet_ids for each post. Ask for more with tweet.fields=created_at,public_metrics and expansions=author_id.

Step 4: Page through results with next_token

Each response carries meta.next_token while more posts match. You send it back as next_token, and stop when it's missing.

X's pagination guide adds:

  • Pages run newest first.
  • A next_token doesn't expire; the same token returns the same page.
  • To poll, pass the first page's meta.newest_id as since_id next time.

This loop caps the pages, so a broad query can't run up a bill:

import os, requests
URL = "https://api.x.com/2/tweets/search/recent"
HEAD = {"Authorization": f"Bearer {os.environ['X_BEARER_TOKEN']}"}

def search_recent(query, max_pages=5):
    params = {"query": query, "max_results": 100, "tweet.fields": "created_at"}
    for _ in range(max_pages):
        r = requests.get(URL, params=params, headers=HEAD, timeout=30)
        r.raise_for_status()
        page = r.json()
        yield from page.get("data", [])
        token = page["meta"].get("next_token")
        if not token:
            return
        params["next_token"] = token

We tested it on 22 October 2026 against a local stub that mimics X's meta fields: it read both pages and stopped.

At 100 posts a page, each page costs 50 cents. So max_pages=5 caps one run at $2.50.

Step 5: Count posts before you pay to read them

The counts endpoints tell you how many posts match a query, without returning the posts:

  • GET /2/tweets/counts/recent covers the last 7 days, for every developer.
  • GET /2/tweets/counts/all reaches back to 2006, on pay-per-use and Enterprise.
  • granularity groups counts by minute, hour (the default) or day.
  • Full-archive counts page every 31 days, through the same next_token.
curl "https://api.x.com/2/tweets/counts/recent?query=from%3Agithub&granularity=day" \
  -H "Authorization: Bearer $X_BEARER_TOKEN"

Each bucket holds a start, an end and a tweet_count. X warns counts may not match search exactly, since search applies extra compliance filtering.

What does the Twitter search API cost?

X bills you $0.005 for each post a search returns, as of October 2026. If a post comes back twice in one UTC day, you pay once.

Reading 10,000 posts through search, October 2026
X recent or full-archive search$50
TwitterAPI.io$1.50
Weir, $5 packabout $2.10

Price your own volume with the X API cost calculator.

Step 6: Search X with Weir's POST /v1/x/search

We run Weir, a read-only API for public X and Reddit data, so weigh this part knowing that. Its search takes JSON fields instead of an operator string.

The fields:

  • Accounts: fromUsers, toUsers and mentions, up to 10 names each, or a listId.
  • Words: query, phrase, anyWords, excludeWords, hashtags and language.
  • Floors: minLikes, minReposts and minReplies.
  • Post type: onlyOriginal drops replies; onlyReplies, onlyLinks and onlyText narrow further.
  • Time: since and until as exact times, or sinceId and untilId.
  • Paging: sort (latest or top), limit up to 100, and cursor.

You can type X operators straight into query, in x.com's dialect, so min_faves: works here.

curl --request POST \
  --url https://api.weirapp.io/v1/x/search \
  --header "Authorization: Bearer $WEIR_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"fromUsers":["github"],"query":"-filter:nativeretweets","onlyOriginal":true,"limit":3}'

We ran it on 22 October 2026 through Weir's MCP server, which takes the same fields. It returned GitHub's three latest posts for 4 credits: 1 for the call and 1 per post. One of them, trimmed:

{
  "id": "2112938664959562081",
  "author": { "username": "github", "followersCount": 2724485 },
  "likeCount": 518,
  "bookmarkCount": 410,
  "viewCount": 70748,
  "quotedPost": { "id": "2112936525457740139", "likeCount": 1564 }
}

Send the response's meta.nextCursor back as cursor, with the body unchanged, until it comes back null. On X the last page often still holds a cursor, so a full walk ends with one empty 1-credit call.

  • Reposts come back by default. Our -filter:nativeretweets keeps them out.
  • Floors are X's own filters. Check likeCount in code if you need an exact floor.

X recent search vs full-archive vs Weir: which to use?

Pick by the job:

If you need Use Price, October 2026
The last 7 days, on X's terms X recent search $5 per 1,000 posts
Older posts, 500 per request X full-archive search $5 per 1,000 posts
How many posts match, over time X counts $0.005 or $0.010 a call
Any year, without an X developer app Weir search $0.11 to $0.21 per 1,000

That range runs from Weir's $1,000 pack to its $5 pack, call credits included.

Why does my X search API call fail or come back empty?

  • 401 Unauthorized: the bearer token is missing or wrong, as in our test above.
  • 400 on one operator: x.com names like min_faves: are rejected; use min_likes:.
  • An empty full-archive page: without start_time, X searched only the last 30 days.
  • 429 Too Many Requests: wait until the Unix time in the x-rate-limit-reset header.

When not to use Weir

  • You need a contract with X. Use its search endpoints.
  • You need post counts or private metrics. Only X's API returns them.
  • Each request must return 500 posts. Weir's pages hold about 20.
  • Price per post is all that matters. TwitterAPI.io lists $0.15 per 1,000 tweets, takes the same search syntax and can post.

Weir reads public data only, can't post, and isn't licensed by X, so access can change. Check X's terms for your use; this isn't legal advice.

FAQ

Is the Twitter search API free?

No. X's pricing page lists no free tier, and you pay $0.005 for each post a search returns, as of October 2026. New pay-per-use accounts can earn up to $70 in starter credits, per X's changelog.

How far back does the X search API go?

Recent search covers the last 7 days. Full-archive search reaches March 2006 for pay-per-use and Enterprise accounts, but returns only the last 30 days unless you set start_time.

How many tweets can I get per request?

You get up to 100 from recent search and 500 from full-archive search, as of October 2026. Pay-per-use accounts can read 3 million posts a month.

Does the Twitter search API return retweets?

Not for keyword searches. X's changelog says that since 4 May 2026, retweets "are no longer returned in keyword-based search results." On x.com and Weir, reposts come back by default, and -filter:nativeretweets drops them.

Sources

All checked on 22 October 2026, with docs.x.com read as Markdown: