Twitter search API with X's operators: free in a browser, pay per post via MCP or API

Twitter search API with X's operators: free in a browser, pay per post via MCP or API
Unif Cookbooks team
Unif Cookbooks team

Updated

Search public X posts with X's operators: free on the search page in a browser, or pay per post from scripts and agents via the UnifAPI MCP server or API.

In short: the X search page searches public X posts in a browser for free, with no login and no account, rate-limited per visitor. Scripts and agents take the paid path: the UnifAPI MCP server at https://mcp.unifapi.com (OAuth sign-in, no key to paste) or GET https://api.unifapi.com/x/tweets/search/recent with a Bearer key. Both take X's search operators in query: from:, to:, since:, until:, min_faves:, min_retweets:, filter:media, filter:links, -filter:replies, lang:, and quoted phrases. You pay 1 credit ($0.001) per post returned, at least 1 credit per call, so a 20-post page costs 2 cents; max_results (1 to 100) sets the page size and pagination_token pages. Each API key gets 60 requests a minute by default, printed in RateLimit-* and X-RateLimit-* headers. Without dates you get the newest posts; add since: and until: and the same search reaches back to 2006.

Of all the things people want from X without an account, search is the one with no good free answer. The link-preview APIs (FxTwitter, vxTwitter) read single posts. The syndication endpoint reads single posts. Nitter had search, and most public Nitter instances are gone or legally blocked. That left either a developer account with a paid tier or a headless browser driving x.com/search, which is slow, fragile, and against the terms.

This is what UnifAPI's search does now: free on a web page for a person, pay per post for code. How to query it, what it costs, and where it stops.

The request

From an agent, add the UnifAPI MCP server (https://mcp.unifapi.com; setup for Claude, ChatGPT, Cursor, Codex and others) and sign in when the client asks; there is no key to paste. The agent finds the operation with list_operations, reads its parameters with get_operation, and runs it with call_api:

{
  "path": "/x/tweets/search/recent",
  "method": "GET",
  "query": { "query": "from:nasa filter:media", "max_results": 20 }
}

From a script, it is the same operation over HTTP with a Workspace API key. Sign in, top up under Billing and create a key under API keys; Connect on any X viewer page runs the same steps in one flow. The X API reference lists every X operation.

curl -sG "https://api.unifapi.com/x/tweets/search/recent" \
  -H "Authorization: Bearer $UNIFAPI_API_KEY" \
  --data-urlencode "query=from:nasa filter:media" \
  -d max_results=20
{
  "request_id": "…",
  "data": [
    {
      "id": "2107566197579341846",
      "text": "After delivering science and supplies to the @Space_Station earlier this year, Northrop Grumman's Cygnus XL cargo spacecraft is scheduled to depart on Friday…",
      "author_id": "11348282",
      "created_at": "Tue Oct 06 20:18:32 +0000 2026",
      "lang": "en",
      "public_metrics": {
        "like_count": 2195,
        "retweet_count": 302,
        "reply_count": 114,
        "quote_count": 20,
        "bookmark_count": 104,
        "impression_count": 1520159
      },
      "author": {
        "id": "11348282",
        "username": "NASA",
        "name": "NASA",
        "verified": true,
        "public_metrics": { "followers_count": 92373839, … }
      },
      "media": [
        {
          "media_key": "…",
          "type": "photo",
          "url": "https://pbs.twimg.com/media/…jpg",
          "width": 1920,
          "height": 1280
        }
      ]
    }
  ],
  "pagination": { "has_more": true, "next_cursor": "DAACCgACHUAq4qFAJxAKAAMd…" },
  "billing": { "credits_charged": 20, "records_charged": 20, "balance_remaining": 1980, "truncated_due_to_balance": false }
}

Field names follow X API v2: public_metrics.like_count for likes, author.username for the handle, and created_at in X's own date format. The author rides along with each post and is not billed on its own; the 20 credits are the 20 posts.

In a browser, the same search is https://unifapi.com/tools/x-search?q=from:nasa filter:media. If you used the old free endpoints under /tools/x/, since October 17, 2026, those URLs answer scripts and agents with HTTP 402 and a body naming the MCP server and the paid operation that replaces each lookup; the viewer pages stay free in a browser. Through the MCP server at https://mcp.unifapi.com or the X API, a call bills 1 credit ($0.001) per returned record and at least 1 credit, so a 20-post search page costs 20 credits ($0.02).

Operators that work

The query goes to X's search as written, on the page and in the API, so the operators X documents for its own search box work here. These are the ones we use most:

OperatorExampleWhat it does
from:from:nasaPosts by one account
to:to:nasaReplies addressed to an account
@handle@nasaPosts mentioning an account
#tag#Formula1Posts with a hashtag
"phrase""crew-12"Exact phrase
since: / until:since:2026-10-01Date bounds (whole days)
min_faves:min_faves:100At least N likes
min_retweets:min_retweets:50At least N reposts
filter:mediafrom:nasa filter:mediaOnly posts with photos or video
filter:linksfilter:linksOnly posts with a link
-filter:replies#Formula1 -filter:repliesExclude replies
-filter:retweetsfrom:nasa -filter:retweetsExclude reposts
lang:lang:jaLanguage code
ORnasa OR esaEither term

They combine. "Posts by NASA in the last week with at least 100 likes and a photo, no replies" is:

from:nasa since:2026-09-30 min_faves:100 filter:media -filter:replies

The search page has a filter for each of the five most common ones (account, date, likes, media, replies) and prints the query they build, which is the same string you send as query.

Recent, not Top

X's search has two rankings: "Top", which mixes relevance and age and will happily lead with a post from 2009, and "Latest", strictly newest first. The search page and the API both ask for Latest. For monitoring, reactions to an event, and anything with a since: bound, that is the one you want. If you want "the most-liked posts about X this week", sort the Latest results yourself by public_metrics.like_count or add min_faves: to cut the tail.

Paging

Every list in the API carries pagination with has_more and next_cursor. To continue, send next_cursor back as pagination_token:

curl -sG "https://api.unifapi.com/x/tweets/search/recent" \
  -H "Authorization: Bearer $UNIFAPI_API_KEY" \
  --data-urlencode "query=#Formula1" \
  --data-urlencode "pagination_token=DAACCgACHUAq4qFAJxAKAAMd…"

Through MCP it is one more key in the call_api query: "pagination_token": "DAACCgACHUAq4qFAJxAKAAMd…".

Cursors are opaque strings; do not parse them. has_more is true exactly when next_cursor is set. The cursor continues after X's own page, not after the last post you were sent, so a max_results smaller than X's page skips the rest of that page. Leave max_results unset (or at 100) when you read a result set end to end, and keep small values for polls that only read the first page. Every page bills the posts on it: reading 60 posts across three pages is 60 credits ($0.06) and 3 of the key's 60 requests a minute.

What it costs, and the rate limit

Search bills 1 credit per post returned, at least 1 credit per call, and a credit is $0.001 (1,000 credits = $1). A 20-post page is 20 credits, two cents; a search that finds nothing costs the 1-credit minimum. There is no subscription: you top up a Workspace balance and calls draw it down. Every response says what it cost in billing. If the balance cannot cover a full page, the call returns as many posts as it covers and sets truncated_due_to_balance; the balance never goes negative, and with nothing left the answer is a 402 insufficient_credits error that carries a top-up path.

Each API key gets 60 requests per minute by default, and every response prints where you stand:

HTTP/2 200
RateLimit-Policy: "api-key";q=60;w=60
RateLimit: "api-key";r=57;t=60
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 60

The reset value counts seconds until the window clears, not a timestamp. Past the limit, the answer is a 429 with Retry-After:

{
  "error": {
    "type": "rate_limited",
    "message": "API key rate limit exceeded.",
    "request_id": "…"
  }
}

A well-behaved agent reads X-RateLimit-Remaining before deciding to page, and sleeps on Retry-After instead of retrying in a loop. The search page in a browser has its own cap, 10 searches per 10 minutes per visitor (a search counts as two of the 20 lookups); Connect on the page switches it to pay as you go with no cap.

What it does not do

  • Relevance. Results are newest first only. Old posts are reachable with dates (from:jack until:2006-04-01 returns posts from March 2006), but nothing ranks the best of a period first, and X draws since:/until: day boundaries in its own time zone, so a range can spill a few hours either side.
  • Non-public posts. Only public posts are returned.
  • Counts. There is no "how many posts matched" number; X does not expose one for search.
  • Free access for code. The search page is free for a person in a browser, with a per-visitor cap. Scripts, agents and crawlers go through MCP or the API and pay per post.

A monitoring loop in twenty lines

import os, time, requests
from datetime import date, timedelta

API = "https://api.unifapi.com/x/tweets/search/recent"
AUTH = {"Authorization": f"Bearer {os.environ['UNIFAPI_API_KEY']}"}
seen = set()

def poll(terms):
    since = (date.today() - timedelta(days=1)).isoformat()
    params = {"query": f"{terms} since:{since}", "max_results": 10}
    r = requests.get(API, headers=AUTH, params=params)
    if r.status_code == 429:
        time.sleep(int(r.headers.get("Retry-After", "60")))
        return []
    r.raise_for_status()
    fresh = [p for p in r.json()["data"] if p["id"] not in seen]
    seen.update(p["id"] for p in fresh)
    return fresh

while True:
    for p in poll('"unifapi" -filter:replies'):
        user = p["author"]["username"]
        print(p["created_at"], user, p["public_metrics"]["like_count"], f"https://x.com/{user}/status/{p['id']}")
    time.sleep(600)

Every poll bills the posts it returns, whether the loop has seen them or not, with a 1-credit minimum. The since: bound keeps a poll to the last day or two and max_results caps it at 10, so at one poll every 10 minutes (144 a day) the ceiling is 1,440 credits, $1.44 a day. A quiet term costs less: if three posts match the window, each poll is 3 credits, 432 a day; if none match, it is the 1-credit minimum, 144 a day. The seen set keeps the loop from printing a post twice; it does not stop the API billing it twice, so the levers are the interval and max_results. At one poll every 30 minutes the ceiling falls to 480 credits a day. A $10 top-up is 10,000 credits: about a week at the 10-minute ceiling, about 20 days at the 30-minute one. If more than ten new posts land between two polls, a poll sees only the newest ten, so a busy term needs a larger max_results or a shorter interval, and costs more. One request every 10 minutes is far under the key's 60 a minute; the loop handles a 429 anyway, and a 402 (balance used up) raises instead of retrying.

FAQ

Is there a free Twitter search API in 2026?

Not for code here. The search page is free for a person in a browser, with no login and no account, capped at 10 searches per 10 minutes per visitor. Scripts and agents search through the UnifAPI MCP server or GET /x/tweets/search/recent and pay 1 credit ($0.001) per post returned. The official X API has no free search tier; its free plan allows posting only.

Do Twitter advanced search operators work?

Yes, on the page and in the API. The query is passed to X's search unchanged, so from:, since:, until:, min_faves:, filter:media, -filter:replies, lang:, and quoted phrases all work.

How far back does search go?

Back to 2006. Without dates you get the newest posts first; add since: and until: to jump to a period, for example from:jack until:2006-04-01.

What does a Twitter search cost through the API?

1 credit per post returned, at least 1 per call, at $0.001 a credit: a 20-post page is $0.02, and a search that finds nothing is $0.001. Credits come from a Workspace top-up, with no subscription. The search page in a browser stays free.