X / Twitter API

X / Twitter Search API

Search X (Twitter) with full advanced-search syntax (operators like from:, since:, until:, min_faves: work inline in the query) and get structured tweets with text, author, engagement, and cursor pagination. Limit is a per-page maximum; native pages contain approximately 20 tweets unless requireSinglePage selects a bulk lane.

POST/v1/run/twitter.search
Uptime
99.92%
30d · 21,089 calls
Requests
21,105
30d · weekly, last 12 wks
Response
2.2s
median · 30d

Try it

Make your first request

requireFieldsarray
Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `nextCursor` or `media`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. On a paginated walk it applies to the first page only; later pages stay with the source that page chose, at the price it was quoted.
Open in
Get a free key
Sample response
Free runs return only the first 3 results. Fund a key to get the full response.
{
  "data": {
    "items": [
      {
        "authorName": "Alex Rivera",
        "authorUsername": "alex_rivera",
        "authorVerified": true,
        "bookmarkCount": 12500,
        "conversationId": "a1b2c3d4",
        "createdUtc": 12.5,
        "id": "a1b2c3d4",
        "isReply": true,
        "lang": "en",
        "likeCount": 12500,
        "media": [
          {
            "height": 42,
            "type": "general",
            "url": "https://example.com/page",
            "videoUrl": "https://example.com/page",
            "width": 1024
          }
        ],
        "quoteCount": 12500,
        "replyCount": 12500,
        "retweetCount": 12500,
        "text": "A short example description of this item.",
        "url": "https://example.com/page",
        "viewCount": 12500
      }
    ],
    "nextCursor": "example"
  },
  "found": true
}
Response interface
interface TwitterSearchResponse {
  data: {
    items: {
      authorName?: string;
      authorUsername?: string;
      authorVerified?: boolean;
      bookmarkCount?: number;
      conversationId?: string;
      createdUtc?: number;
      id: string;
      isReply?: boolean;
      lang?: string;
      likeCount?: number;
      media?: {
        height?: number;
        type: string;
        url: string;
        videoUrl?: string;
        width?: number;
      }[];
      quoteCount?: number;
      replyCount?: number;
      retweetCount?: number;
      text: string;
      url: string;
      viewCount?: number;
    }[];
    nextCursor?: string | null;
  } | null;
  found: boolean;
}

Full parameter and response reference - every field, type, and example for this endpoint.

Reference

Request, response, and price

Last verified 2026-09-16 · uptime and latency measured over 30d
POST /v1/run/twitter.search
curl -X POST https://api.getanyapi.com/v1/run/twitter.search \
  -H "Authorization: Bearer $ANYAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"openai"}'
FieldTypeExample value
Request body
querystring"openai"Search query using X (Twitter) advanced-search syntax. IMPORTANT: bare terms are ANDed - a tweet must contain EVERY word, so a list of loosely related keywords matches nothing; use one short phrase or OR between alternatives (e.g. 'anyapi OR getanyapi'). You can embed X advanced-search operators directly in the query to filter results: from:username and to:username (author or recipient), since:YYYY-MM-DD and until:YYYY-MM-DD (date range), min_faves:N, min_retweets:N, min_replies:N (engagement floors), "exact phrase", -term to exclude, filter:media and filter:links and -filter:replies (content filters), lang:en, near:city, and geocode:lat,long,radius. Examples: 'from:OpenAI', 'AI agents min_faves:500 -filter:replies', 'nvidia since:2026-01-01 until:2026-03-01'. A query with no matches returns an empty items array; prefer the fewest words that identify the topic.
cursorstringOpaque pagination cursor from a previous response's nextCursor. Omit for the first page; pass it to fetch the next page of search results.
limitintegerPer-page maximum number of results to return (1-50, default 20). A provider may return a smaller native page; follow nextCursor for more.
queryTypeenumResult ranking: 'Latest', 'Top', 'Photos', or 'Videos' (e.g. Latest).
requireFieldsarrayOptional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `nextCursor` or `media`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. On a paginated walk it applies to the first page only; later pages stay with the source that page chose, at the price it was quoted.
requireSinglePagebooleanSet true to get up to limit results in one response instead of provider-native pages, served by a bulk provider when needed.
Response
dataobject
data.itemsobject[]Tweet records: text, author profile, timestamp, and engagement metrics (likes, retweets, replies, views). Populated whenever the provider has data for the entity.
data.items[].authorNamestringPopulated whenever the provider has data for the entity.
data.items[].authorUsernamestringPopulated whenever the provider has data for the entity.
data.items[].authorVerifiedcan requireboolean
data.items[].bookmarkCountcan requireinteger
data.items[].conversationIdcan requirestring
data.items[].createdUtcnumberUTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds. Populated whenever the provider has data for the entity.
data.items[].idstringPopulated whenever the provider has data for the entity.
data.items[].isReplycan requireboolean
data.items[].langcan requirestring
data.items[].likeCountcan requireinteger
data.items[].mediacan requireobject[]Photo, video, and GIF attachments on the post. Empty when the post has none.
data.items[].media[].heightintegerPixel height of the media item, when the lane reports it.
data.items[].media[].typestringOne of photo, video, or gif.
data.items[].media[].urlstringImage URL. For a video or GIF this is the poster/thumbnail frame. X media URLs on pbs.twimg.com are publicly fetchable without authentication; append ?name=orig for the full-resolution original.
data.items[].media[].videoUrlstringPlayable video file URL. Present only for video and gif items.
data.items[].media[].widthintegerPixel width of the media item, when the lane reports it.
data.items[].quoteCountcan requireinteger
data.items[].replyCountcan requireinteger
data.items[].retweetCountcan requireinteger
data.items[].textstringPopulated whenever the provider has data for the entity.
data.items[].urlstringPopulated whenever the provider has data for the entity.
data.items[].viewCountcan requireinteger
data.nextCursorcan requirestringOpaque cursor for the next page of search results, or null when there are no more. Pass it back as cursor to continue.
foundboolean
Price
Price per requestUSD$0.00065
Price /1k reqUSD$0.65

FAQ

About the X / Twitter Search API

The AnyAPI X / Twitter Search API returns X / Twitter search data as normalized JSON from one POST call to /v1/run/twitter.search. Search X (Twitter) with full advanced-search syntax (operators like from:, since:, until:, min_faves: work inline in the query) and get structured tweets with text, author, engagement, and cursor pagination. Limit is a per-page maximum; native pages contain approximately 20 tweets unless requireSinglePage selects a bulk lane. AnyAPI routes each request across 4 sources and falls back automatically when one fails. It costs from $0.65 per 1,000 requests, in US dollars with no subscription and no monthly minimum. Over the last 30 days, 99.9% of X / Twitter search calls through AnyAPI succeeded, with a median response time of 2.2 seconds across 21,089 measured calls.

It costs from $0.65 per 1,000 requests, in US dollars with no subscription and no monthly minimum. You fund one USD wallet, each call draws it down, and a failed request costs $0.

Search X (Twitter) with full advanced-search syntax (operators like from:, since:, until:, min_faves: work inline in the query) and get structured tweets with text, author, engagement, and cursor pagination. Limit is a per-page maximum; native pages contain approximately 20 tweets unless requireSinglePage selects a bulk lane. The response is normalized JSON with the same envelope every AnyAPI endpoint returns, so parsing a second endpoint is a change of URL and nothing else.

Over the last 30 days, 99.9% of X / Twitter search calls through AnyAPI succeeded, with a median response time of 2.2 seconds across 21,089 measured calls. These are AnyAPI's own measurements of traffic through the gateway, recomputed continuously, not a published service-level target.