READ API LIVEBuild on /v1 for search, profiles, timelines, audience graph, and tweet context.READ DOCS

X/Twitter data · Search API

Twitter Search API for public posts by keyword

Find public X/Twitter posts about your brand, product or market. Filter by keywords, hashtags and accounts, then use the JSON results in your app or AI pipeline.

Try live search Demo

See a real response before signing up

ai agents min_faves:50 lang:en -filter:replies
Demo query
Fixed, no API key needed
Up to
5 posts per Demo
Custom queries
1,000 free starting credits

Start with your question

Search tweets by keyword, hashtag or account

A Twitter Search API turns a query into post records your software can read. Start with one of these examples and replace the topic or account with your own.

Brand and product conversations

(openai OR "chatgpt") lang:en -filter:replies

Find posts naming a brand or product. Use alternatives for different names and exclude replies when you want standalone discussions.

Hashtags and market research

(#bitcoin OR $BTC) min_faves:100 lang:en -filter:replies

Follow a hashtag or cashtag with an engagement filter. Use the matches as a research sample for your market dashboard.

Posts from a known account

from:openai filter:links -filter:replies

Find an account's posts that include links. Send the text, timestamps and post IDs into your research or AI pipeline.

Your first search

Run your own query with cURL or Python

Create an xfetch API key and set it as XFETCH_API_KEY in your environment. Replace query below with your search. This example requests up to 20 posts; the returned count can be smaller.

GET/v1/search/recent
Your API key
cURL
curl --get 'https://api.xfetch.io/v1/search/recent' \
  -H "Authorization: Bearer $XFETCH_API_KEY" \
  --data-urlencode 'query="AI agents" lang:en -filter:replies' \
  --data 'limit=20'
Python · requests
import os
import requests

response = requests.get(
    "https://api.xfetch.io/v1/search/recent",
    headers={"Authorization": "Bearer " + os.environ["XFETCH_API_KEY"]},
    params={"query":"\"AI agents\" lang:en -filter:replies","limit":20},
    timeout=30,
)
response.raise_for_status()
result = response.json()
for post in result["data"]:
    print(post["id"], post["text"])

Let your HTTP client encode the query so spaces, # and $reach the API correctly. The Python example uses the requests package. For all request parameters, see the recent-search API reference.

See an illustrative JSON response

This saved example shows the response structure, not current search results. Basic search returns posts in data[]. Each record includes an ID, text, author ID, timestamp and available engagement metrics.

GET/v1/search/recent
Response example
JSON
{
  "data": [
    {
      "id": "1234567890123456789",
      "text": "xfetch ships /v1 today.",
      "author_id": "783214",
      "created_at": "2026-05-23T12:00:00.000Z",
      "lang": "en",
      "conversation_id": "1234567890123456789",
      "possibly_sensitive": false,
      "like_count": 5,
      "retweet_count": 1,
      "reply_count": 0,
      "quote_count": 0,
      "bookmark_count": 0,
      "is_quote_status": false,
      "entities": {
        "hashtags": [],
        "urls": [],
        "mentions": []
      }
    }
  ],
  "meta": {
    "request_id": "req_01HXFETCHEXAMPLE",
    "credits": {
      "charged": 2,
      "remaining": 998
    },
    "pagination": {
      "next_token": "tok_2"
    }
  }
}

Take a complete research task further

Collect matching posts and author profiles, follow pages, remove duplicates, and download a readable report with JSON/CSV files.

Run the topic search template →

Refine your results

Twitter search operators for useful queries

FindOperatorExample
An exact phrase"…""AI agents"
Either topicOR, ()(bitcoin OR ethereum)
Posts from an accountfrom:from:openai
A languagelang:lang:en
A date rangesince:, until:since:2026-09-01 until:2026-09-05
Posts with engagementmin_faves:, min_retweets:min_faves:50
A hashtag or cashtag#, $#ai, $BTC
Links; exclude replies or termsfilter:links, -filter:links -filter:replies

These are xfetch search-query examples. A date filter narrows results within available recent coverage; it does not turn this endpoint into a full archive. For an existing official API integration, see the separate X API compatibility guide.

Continue your search

Page through results with next_token

  1. Send your first request with query and limit.
  2. Read meta.pagination.next_token from the response.
  3. Pass next_token unchanged. Keep the endpoint, query, limit and sort order the same.
  4. Stop when the token is absent. Deduplicate by post ID when running a fresh search later.

Keep the context your application needs

data[].id · data[].text · data[].author_id · data[].created_atUse created_at to check the result window. Request enriched search when you also need the authors' public profile fields.

Choose the data you need

Twitter Search API pricing: basic or enriched?

Choose basic search for post records. Choose enriched search for posts plus a deduplicated author set, such as bios and public follower counts. New accounts receive 1,000 credits to try their own queries.

Search modeReturnsCredit rule5 posts20 posts
Basic search
/v1/search/recent
Post records in data[]1 base + 1 per item6 credits21 credits
Enriched search
/v1/search/recent/enriched
data.tweets + data.authors1 base + 2 per item11 credits41 credits

A priced item is a returned post in both modes. Join enriched results using tweet.author_id = author.id; handle a missing author when a profile is unavailable. Successful pages use the returned count, including the base charge for an empty page. Failed requests are not charged. Check credit packs and estimate your budget with the pricing calculator.

Inspect the data first

Try a live search response without signing up

The public Search Demo runs the fixed query shown at the top of this page. It is rate-limited and may briefly reuse a recent successful response. Use the live status page to inspect sample timestamps and recent check results.

Before you integrate

Twitter Search API questions

What is a Twitter Search API?
A Twitter Search API retrieves public posts matching a query so you can use them in software. xfetch returns post text, IDs, author IDs, timestamps and available engagement metrics as JSON for social listening, research and AI applications.
Can I search tweets by keyword, hashtag or username?
Yes. Put keywords, quoted phrases, #hashtags or $cashtags in query. Use from:username for posts from a known account, lang:en for English, and -filter:replies to exclude replies. This searches posts; it does not search a directory of user profiles.
Do I need an X developer account or an API key?
Custom queries use an xfetch API key in the Authorization: Bearer header. You do not supply X developer credentials. You can inspect the fixed public Search Demo without signing in; create an xfetch account to run your own query.
Can I search historical tweets or get every matching post?
This endpoint is for recent public search. Date operators narrow a query, but do not provide a guaranteed historical lookback or an exhaustive archive. Check returned created_at values against the period your research needs. For a known account's new-post alerts, use account monitoring.
How do I paginate Twitter search results?
Pass meta.pagination.next_token unchanged as next_token on your next request. Keep the same endpoint, query, limit and sort_order. Stop when the token is absent. Store post IDs to deduplicate records when you run the query again later.
When should I use enriched search?
Choose basic search when post records are enough. Choose enriched search when you also need author bios or public follower metrics: it returns data.tweets and data.authors, joined by tweet.author_id and author.id. Some author profiles may be unavailable, so handle missing matches.
Are empty results and failed requests charged?
A successful empty search still uses the base charge shown in the pricing table. A failed request is not charged. Check meta.credits.charged for the amount charged on each successful page.

Build on the result

From search results to account research

Recent search is a pull workflow for keywords and topics. For a known account's new-post alerts, use the Twitter webhook and account monitor.

Maintained by xfetch. Last updated .

Run the query your product needs.

Get 1,000 free starting credits. Google sign-in opens the search playground with an editable example ready to run.