Social media5 min readBy Purrkey teamUpdated

How to search X posts with advanced operators

Search X posts with advanced-search operators and get structured tweet records with author and engagement data

On this page

You need 40 recent X posts about AI agents with at least 500 likes, and a table of post text, author, and engagement metrics to decide which post themes to brief for next week's content calendar. One query with advanced-search operators can return the records, and a cursor keeps the pages in order

The table below is the deliverable design. No run has been executed for this article. Values here are placeholders showing the shape

Example query and table design

Example query:

AI agents min_faves:500 -filter:replies since:2026-01-01

This is the input string; replace it with your own. The agent returns one row per post with these columns

textauthorUsernameauthorNamecreatedUtclikeCountretweetCountreplyCountviewCounturltopic tag
placeholderplaceholderplaceholderplaceholderplaceholderplaceholderplaceholderplaceholderplaceholderplaceholder

The final column is a reader-added topic tag. Leave it empty in the agent prompt and fill it after you read the post text. If your job starts with a list of post URLs instead of a query, the companion guide at https://purrkey.app/blog/list-community-tweets-by-url covers that separate task

Input fields and query syntax

The contract documents query as required. The optional inputs are cursor, limit, queryType, requireSinglePage, and requireFields. query holds the X advanced-search string, so operators go inline: from:username, to:username, since:YYYY-MM-DD, until:YYYY-MM-DD, min_faves:N, min_retweets:N, min_replies:N, "exact phrase", -term, filter:media, filter:links, -filter:replies, lang:en, near:city, and geocode:lat,long,radius. A bare list of terms is ANDed, so a tweet must contain each word; use one short phrase or OR between alternatives. When an operator follows an OR list, put the list in parentheses, as in (anyapi OR getanyapi) -filter:replies

queryType defaults to Latest; the other values are Top, Photos, and Videos. Photos and Videos search the query as written with filter:images or filter:videos added after it, and they cost the same as a Latest search. requireSinglePage set true asks for up to limit results in one response instead of provider-native pages. requireFields is optional; naming nextCursor can route to a dearer source, and a combination no single source returns together is refused as invalid input, with no charge

Read the output fields that drive the decision

The response has found and data. When found is true, data.items holds tweet records and data.nextCursor holds the cursor for the next page or null. A found: false answer with reason: not_found is a successful call, not an error, and costUsd is what it actually cost

For the content calendar, read text, authorUsername, authorName, createdUtc, likeCount, retweetCount, replyCount, viewCount, and url from each item. createdUtc is a UTC epoch timestamp in seconds; multiply by 1000 for a JS Date in milliseconds. viewCount is null when the source does not report it. The query includes min_faves:500; the table records likeCount so the floor is visible next to the post. Keep rows that meet the floor, then add the topic tag by reading text. The item can also carry authorFollowers, authorVerified, bookmarkCount, quoteCount, media, lang, and conversationId; the design table stays on the fields named in the brief

Page through results without losing the boundary

limit is a per-page maximum from 1 to 50, default 20. It is not a cap on the full walk. Native pages contain approximately 20 tweets unless requireSinglePage selects a bulk lane, and a response is not trimmed after the call. Use nextCursor from a response as the cursor input to continue exactly where that page ended. A one-call plan uses requireSinglePage: true with limit 40. A native-page route follows the cursor until the table has 40 rows or nextCursor is null

The agent prompt

Example prompt; replace the query with your own

Agent prompt
Set up https://purrkey.app/SKILL.md, then use Purrkey to search X posts for the query below. Check the current inputs and price of anyapi.twitter.search before running. Run the search with query "AI agents min_faves:500 -filter:replies since:2026-01-01", requireSinglePage true, and limit 40. If the response has a nextCursor and the table has fewer than 40 rows, call again with that cursor until the table has 40 rows or nextCursor is null. Return a table with text, authorUsername, authorName, createdUtc, likeCount, retweetCount, replyCount, viewCount, url, and topic tag. Leave topic tag empty. Do not invent posts or values.

Estimated tool cost

The catalog lists anyapi.twitter.search called through POST /v1/runs with toolId anyapi.twitter.search, unit max_call, up to $0.0154 per call (unitPriceMicros 15400), priceRevision anyapi-catalog-2026-11-05, read through the Purrkey catalog on November 13, 2026. max_call means "Maximum per call. Successful runs settle at the actual AnyAPI charge." The totals below are ceilings, not settled charges. Model fees for the agent are not counted

StepFormulaUnit pricePlanned quantityTotal
Single page1 call x max price$0.0154 per call1$0.0154
Three-page cursor walk3 calls x max price$0.0154 per call3$0.0462

Next action

Open https://purrkey.app/tools/twitter?q=search and run the query with requireSinglePage: true, limit 40, and your operator string

Get started by giving this to your agent

  • Claude Code
  • Codex
  • Gemini CLI
  • Cursor
  • GitHub Copilot
Set up https://purrkey.app/SKILL.md, then use Purrkey to show me what I can do with X (Twitter).
Explore X (Twitter) tools and pricing

FAQ

How do I search X posts with advanced operators?

Put the operators inside the query string for anyapi.twitter.search, such as min_faves:500, since:2026-01-01 and -filter:replies. The response returns tweet records and a cursor for the next page.

What inputs does anyapi.twitter.search take?

The contract documents query as required, plus optional cursor, limit, queryType, requireSinglePage and requireFields. Naming nextCursor in requireFields can route to a dearer source.

What does nextCursor do in anyapi.twitter.search?

nextCursor is the opaque cursor for the next page, or null when there are no more results. Pass it as cursor to continue exactly where the response ended.

How many posts come back per call?

limit is a per-page maximum from 1 to 50, default 20. Native pages contain approximately 20 tweets unless requireSinglePage selects a bulk lane, and a response is not trimmed after the call.

How much does a 40-post X search cost?

At the catalog price of up to $0.0154 per call, a one-call plan is at most $0.0154 and a three-page cursor walk is at most $0.0462. The max_call price is a ceiling, and successful runs settle at the actual AnyAPI charge.

What happens when an X search finds no posts?

A query with no matches returns an empty items array. A found false answer with reason not_found is a successful call, not an error, and costUsd is what it actually cost.

Can I use requireFields to ask for nextCursor?

Yes. Naming nextCursor in requireFields can route the request to a source that returns it, and that can raise the price. A combination no single source returns together is refused as invalid input, with no charge.

Next step

Try this with X (Twitter)

The tool directory lists every endpoint with its current price. Inspect the inputs there, then let your agent run a small batch before scaling up.

See X (Twitter) tools

Share this article