How to Scrape Tweets by Keyword
To scrape tweets by keyword, put the keyword query in the searchTerms input of apidojo's Tweet Scraper V2 on Apify, set sort and maxItems, and run it.

To scrape tweets by keyword, put the keyword query in the searchTerms input of apidojo’s Tweet Scraper V2 on Apify, set sort and maxItems, and run it. The actor returns every matching post with its text, author, date and engagement counts, at $0.40 per 1,000 tweets.
This guide covers how to write keyword queries that return clean data, how to run several keywords in one batch, and how to track which keyword found each post. The overview of every Twitter scraping task is in how to scrape Twitter data in 2026.
How Do You Scrape Tweets by Keyword With Tweet Scraper V2?
You scrape tweets by keyword by testing the query in X search, pasting it into searchTerms, and downloading the dataset after the run. Listed below are the 5 steps.
- Test the query in X search; the actor fetches what that search shows (Apify).
- Open Tweet Scraper V2 and paste the query into
searchTerms. - Set
tweetLanguagefor a language,sorttoLatest,ToporLatest + Top, andmaxItemsfor the cap. - Run the actor.
- Export the dataset as JSON, CSV or Excel.
{
"searchTerms": ["\"electric car\" -filter:retweets"],
"tweetLanguage": "en",
"sort": "Latest",
"maxItems": 5000
}
How Do You Write a Keyword Query for Scraping?
Write a scraping query that is narrow enough to exclude noise and broad enough to return at least 50 tweets, the actor’s minimum per query. The keyword operators are the same as on X; see how to search tweets by keyword. Listed below are the 5 rules for clean keyword data.
- Quote phrases so words stay together:
"electric car". - Group synonyms with uppercase OR in parentheses:
("electric car" OR "EV"). - Exclude noise words:
jaguar -carfor the animal. - Remove reposts so each post appears once:
-filter:retweets. - Add an engagement floor for signal over volume:
min_faves:10.
Complex nesting is covered in how to build complex Twitter search queries.
How Do You Scrape Several Keywords at Once?
To scrape several keywords at once, list each query as its own item in searchTerms and turn on includeSearchTerms to tag each post with the query that found it. Tweet Scraper V2 runs one concurrent run with up to 5 batched queries (Apify).
{
"searchTerms": [
"\"electric car\" -filter:retweets",
"\"heat pump\" -filter:retweets",
"\"solar panel\" -filter:retweets"
],
"includeSearchTerms": true,
"sort": "Latest"
}
A post can match more than one keyword, so deduplicate on the post id after the run.
How Do You Scrape Keyword Tweets With Python?
To scrape keyword tweets with Python, call Tweet Scraper V2 through the Apify client and read the run’s dataset. The fields used below come from the actor’s output example (Apify).
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("apidojo/tweet-scraper").call(run_input={
"searchTerms": ['"electric car" -filter:retweets', '"heat pump" -filter:retweets'],
"includeSearchTerms": True,
"tweetLanguage": "en",
"sort": "Latest",
"maxItems": 2000,
})
seen = {}
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
seen[item["id"]] = item
for tweet in seen.values():
print(tweet["createdAt"], tweet["author"]["userName"], tweet["likeCount"], tweet["text"][:80])
The full Python setup is in how to collect tweets with Python.
What Does a Keyword Scrape Cost?
A keyword scrape costs $0.40 per 1,000 tweets on Tweet Scraper V2, so 50,000 posts cost $20. Queries that return fewer than 50 tweets belong on Twitter Scraper Unlimited, which charges $0.016 per query plus from $0.0004 per item beyond the first 40 (Apify).
| Posts | Tweet Scraper V2 | X API at $0.005 per post |
|---|---|---|
| 10,000 | $4 | $50 |
| 50,000 | $20 | $250 |
| 500,000 | $200 | $2,500 |
X API rates are from X’s documentation (X API pricing); the full comparison is in X API vs Twitter scraper API.
Why Does a Keyword Scrape Return Fewer Tweets Than Expected?
A keyword scrape returns fewer tweets when the query is too narrow, maxItems is set low, or X search itself returns fewer posts for the query. The actor returns what X serves, and some posts are filtered by X (Apify). Listed below are the 5 fixes.
- Clear or raise
maxItems. - Switch
sorttoToporLatest + Top. - Split the query into date ranges; see how to scrape tweets by date range.
- Rule out a low ceiling before blaming the query, the way an X replies run that under-returns is diagnosed.
- Loosen one filter at a time.
Questions people ask
Can you scrape tweets by hashtag?
Yes, put the hashtag in searchTerms: #AI lang:en.
Can you monitor a keyword continuously?
Not with repeated Tweet Scraper V2 runs, which its policy forbids; use the method in how to monitor a keyword on X with an API.
Do you need an X account?
No, you need only an Apify account on a paid plan to use the actor through the API.
Where do you start?
At the apidojo Twitter Scraper.