Twitter (X) Posts Search Scraper avatar

Twitter (X) Posts Search Scraper

Pricing

from $1.00 / 1,000 results

Go to Apify Store
Twitter (X) Posts Search Scraper

Twitter (X) Posts Search Scraper

Search Twitter/X posts by keyword (advanced search). Latest/Top tabs, multiple keywords, date and media/engagement/verified filters, auto-pagination. Returns text, author, favorites, retweets, replies, quotes, views and media. Compatible with api-ninja/x-twitter-advanced-search.

Pricing

from $1.00 / 1,000 results

Rating

0.0

(0)

Developer

code craker

code craker

Maintained by Community

Actor stats

0

Bookmarked

4

Total users

2

Monthly active users

4 days ago

Last modified

Share

Scrape Twitter/X posts by keyword without the official API. This actor runs an X advanced search for one or many keywords, auto-paginates the results, and exports every matching tweet as structured JSON โ€” text, author, likes, retweets, replies, quotes, views, media, hashtags and timestamps. Results can be downloaded as JSON, CSV, Excel or accessed via the Apify API.

The output is built for pipelines: flat items with id_str, url, text, created_at, engagement counts and a full user author object, so it slots straight into existing data workflows.

Features

  • ๐Ÿ” Keyword search โ€” single keyword, exact phrases ("like this"), or many keywords per run, each searched separately and de-duplicated.
  • ๐Ÿ—‚ Latest & Top tabs โ€” chronological or engagement-ranked results.
  • ๐Ÿ“… Date filters โ€” since/until bounds, applied as search operators and re-checked on every scraped tweet.
  • ๐ŸŽ› Content filters โ€” links, hashtags, mentions, news, safe content, questions, verified / blue-verified authors, language.
  • โ™พ Auto-pagination โ€” scrolls until your target tweet count is reached or the feed runs dry (up to 5,000 per run).
  • ๐Ÿ’พ Incremental results โ€” tweets are pushed to the dataset as each keyword finishes, so long runs never lose collected data to a timeout.
  • ๐Ÿ” Flexible authentication โ€” session cookies, secret env vars, or fully automated login with session caching.
  • ๐Ÿ›  Debuggable failures โ€” on empty runs the actor saves a screenshot and the page HTML to the run's key-value store.

Use cases

  • Brand, product and competitor monitoring
  • Sentiment analysis and social listening pipelines
  • Market and academic research
  • Lead generation and trend discovery

Quick start

  1. Enter one or more keywords.
  2. Provide a session (see Authentication below) โ€” a throwaway X account's cookies or credentials.
  3. Run. Tweets appear in the dataset as each keyword completes.

Input

FieldTypeDescription
querystringOne keyword/phrase. Several keywords can be pasted one per line. Advanced-search operators (from:, "exact phrase", ...) pass through as-is.
queriesarrayMultiple keywords โ€” each searched separately, results combined and de-duplicated by tweet. numberOfTweets applies per keyword.
search_typestringLatest (chronological) or Top (ranked). Default Latest.
numberOfTweetsintegerTarget tweets per keyword (max 5000). Default 100.
scrapeAllbooleanAuto-paginate until the target is reached. When false only the first page is returned. Default true.
timeSince / timeUntilstringyyyy-mm-dd date bounds โ€” applied as since:/until: operators and re-checked on the scraped tweets.
languagestringISO 639-1 code, applied as lang:.
contentQuestionMarksbooleanQuestions only (? operator).
engagementHasEngagementbooleanfilter:has_engagement.
mediaHasHashtags / mediaHasLinks / mediaHasMentionsbooleanfilter:hashtags / filter:links / filter:mentions.
mediaNewsOnly / mediaSafeContentOnlybooleanfilter:news / filter:safe.
usersBlueVerifiedOnly / usersVerifiedOnlybooleanfilter:blue_verified / filter:verified.
cookiesarrayCookies of a logged-in X session (Cookie-Editor/EditThisCookie JSON export). The auth_token + ct0 cookies carry the session.
twUsername / twPassword / twEmailstringCredentials for automated login (2FA must be disabled). The email answers X's occasional identity check.
proxyConfigurationobjectProxy settings. Residential proxies strongly recommended.
headlessbooleanUncheck only for local debugging.

Authentication

X login-walls search for anonymous visitors, so the actor needs a session. It resolves one in this priority order:

  1. the cookies input (per-run),
  2. the TW_COOKIES secret env var (JSON cookie array or a name=value; name2=value2 header string),
  3. the session cached in the twitter-session key-value store by a previous automated login,
  4. automated login with twUsername/twPassword (or the TW_USERNAME/TW_PASSWORD/TW_EMAIL secret env vars) โ€” the fresh session is cached for future runs.

Always use a throwaway account, never a personal one. Accounts used for scraping can be restricted by X.

Output

One dataset item per tweet:

{
"id": "1234567890123456789",
"id_str": "1234567890123456789",
"url": "https://x.com/user/status/1234567890123456789",
"twitterUrl": "https://twitter.com/user/status/1234567890123456789",
"text": "Tweet text...",
"full_text": "Tweet text...",
"lang": "en",
"created_at": "2026-05-01T09:30:00.000Z",
"createdTime": "2026-05-01T09:30:00.000Z",
"favorites": 12,
"retweets": 3,
"replies": 4,
"quotes": 1,
"bookmarks": 2,
"views": 4520,
"hashtags": ["health"],
"mentions": ["someuser"],
"urls": ["https://example.com/article"],
"media": [{ "type": "photo", "url": "https://pbs.twimg.com/media/...", "expanded_url": "...", "video_url": null }],
"is_retweet": false,
"is_quote": false,
"is_reply": false,
"conversation_id_str": "1234567890123456789",
"possibly_sensitive": false,
"user": {
"id_str": "987654321",
"name": "User Name",
"screen_name": "user",
"url": "https://x.com/user",
"followers": 1500,
"following": 300,
"tweets": 8200,
"verified": false,
"blue_verified": true,
"avatar": "https://pbs.twimg.com/profile_images/...",
"created_at": "2015-03-01T00:00:00.000Z",
"location": "Harare"
},
"username": "user",
"authorName": "User Name",
"author": { "id": "987654321", "name": "User Name", "username": "user", "profileUrl": "https://x.com/user" },
"searchQuery": "econet",
"search_type": "Latest",
"scrapedAt": "2026-07-03T12:00:00.000Z"
}

How it works

The actor opens x.com/search in a Playwright-driven Chrome with an authenticated session, intercepts the SearchTimeline GraphQL responses that X streams to the page, and scrolls to auto-paginate. Parsing walks the GraphQL JSON generically instead of hardcoding one payload path, so it survives X's frequent payload-shape changes.

FAQ & troubleshooting

Why do I get 0 results? Almost always an expired/missing session or a blocked proxy IP. Check DEBUG_SCREENSHOT and DEBUG_HTML in the run's key-value store to see exactly what the browser saw. Also verify the keyword actually has matches on x.com/search.

Login fails โ€” what now? The error message says which check X raised (identity confirmation, confirmation code/2FA, Arkose CAPTCHA, suspension) and what to do about it. Logging the account in manually once from the proxy's region usually clears security checks. When in doubt, export cookies from a logged-in browser session and pass those instead.

Navigation timeouts? Use Apify Proxy with the RESIDENTIAL group; datacenter IPs are widely blocked by X.

Is this legal? The actor extracts only publicly visible data. You are responsible for complying with X's Terms of Service and applicable laws (e.g. GDPR) for your use case โ€” consult a lawyer if unsure.