X.com Twitter API Scraper
Pricing
from $0.25 / 1,000 each tweet. cheaper for higher plans
X.com Twitter API Scraper
Scrape tweets from X (Twitter) by keyword, advanced search query, hashtag, profile, list or tweet URL, including replies to a tweet. Filter by date, language, engagement, media and verified authors. Get text, views, likes, retweets and author data. No login.
Pricing
from $0.25 / 1,000 each tweet. cheaper for higher plans
Rating
3.5
(7)
Developer
xtdata
Maintained by CommunityActor stats
50
Bookmarked
3.1K
Total users
71
Monthly active users
15 hours ago
Last modified
Categories
Features
Share
X.com Twitter API Scraper - Fast and Efficient Tweet Extraction
This Actor provides a powerful and efficient way to scrape data from Twitter (now X). It allows you to extract tweets based on various criteria, making it ideal for researchers, entrepreneurs, data analysts, and anyone needing to gather Twitter data for analysis, and for following new tweets on a schedule.
Key Features
-
Multiple Input Methods: Get the data you need, how you need it:
- Start URLs: Provide URLs of user profiles,
/with_replies,/media, searches, hashtags, or lists (x.com or twitter.com). - Search Terms: Use keywords and advanced search operators ( see Advanced Search Guide).
- Twitter Handles: Extract tweets from specific users.
- Conversations: Get the replies of tweets by tweet URL, tweet ID, or conversation ID.
- Start URLs: Provide URLs of user profiles,
-
Powerful Filtering: Refine your results with precise filtering:
- Maximum Items: Control the number of tweets per query (each URL, search term, handle, or conversation).
- Sorting: Get results sorted by "Top" or "Latest".
- Language: Filter by language using ISO 639-1 codes (a full list of supported languages is available in the Actor's input settings).
- User Verification: Target tweets from verified users or Twitter Blue subscribers.
- Media Type: Extract only tweets containing images, videos, or quotes.
- Users, Engagement, and Location:
author,inReplyTo,mentioning,minimumFavorites,minimumRetweets,minimumReplies,geotaggedNearwithwithinRadius, orgeocode. - Date Range: Specify a start and end date to retrieve tweets within a specific timeframe.
-
Advanced Options:
- Include Search Terms: Add a field to each tweet showing the search term that matched it.
- Custom Map Function: Transform the output data using a custom JavaScript function (for data shaping, not filtering).
- Monitoring: Turn on
onlyNewTweetsand schedule the Actor to get only tweets you have not seen before.
-
Fast:
- Multiple search terms, handles and URLs run in parallel, so big batches finish quickly.
-
Pay per result:
- You pay per tweet saved to the dataset. The price per tweet depends on your Apify plan and is listed in the Pricing tab. Higher plans pay less per tweet.
**Tutorial from development team: Tutorial: Scrape Twitter Data with Apify's Tweet X.com Scraper **
Server Mode (real-time HTTP API)
Call this Actor as a real-time HTTP API via Apify Standby (https://xtdata--twitter-x-scraper.apify.actor) and receive tweets directly in the JSON response:
GET
curl -H "Authorization: Bearer <APIFY_TOKEN>" \"https://xtdata--twitter-x-scraper.apify.actor/tweets?handle=NASA&maxItems=20&sort=Latest"
POST
curl -X POST "https://xtdata--twitter-x-scraper.apify.actor/tweets" \-H "Authorization: Bearer <APIFY_TOKEN>" \-H "Content-Type: application/json" \-d '{"searchTerms": ["from:NASA"], "maxItems": 20, "sort": "Latest", "tweetLanguage": "en"}'
- Pagination: Single-query requests return
meta.nextCursorandmeta.hasMore. Passcursor=<nextCursor>in the next GET/POST request to continue fetching older pages. - Limits: Up to 200 tweets per query (default 20), 5 queries per request; requests must finish within 5 minutes (
meta.partial = trueif cut short by deadline or budget).onlyNewTweetsis only available in scheduled batch runs. - Cost: Charges
result-itemper returned tweet andqueryper query directly (no dataset push);startis charged once per server run; idle time counts as platform usage.
Use with AI Agents (MCP)
Connect this Actor to Claude Desktop, Cursor, or any MCP-compatible AI agent:
{"mcpServers": {"apify-twitter-x": {"url": "https://mcp.apify.com/?tools=xtdata/twitter-x-scraper","headers": {"Authorization": "Bearer <YOUR_APIFY_TOKEN>"}}}}
Use Cases
- Market Research: Analyze trends, sentiment, and brand perception.
- Academic Research: Gather data for social media studies, political science research, and more.
- Competitive Analysis: Track competitors' activities and public engagement.
- Data Journalism: Uncover insights and patterns within Twitter data.
- Historical Data Analysis: Explore past tweets for specific events or periods.
Quick Start Examples
Here are some example input configurations to get you started quickly:
1. Searching Tweets of a Specific Profile over Several Time Periods:
This example searches English tweets about AI from @elonmusk in several date ranges, sorted by Top.
{"includeSearchTerms": false,"onlyImage": false,"onlyQuote": false,"onlyTwitterBlue": false,"onlyVerifiedUsers": false,"onlyVideo": false,"searchTerms": ["from:elonmusk AI since:2023-01-01 until:2023-03-01","from:elonmusk AI since:2023-03-01 until:2023-05-01","from:elonmusk AI since:2023-05-01 until:2023-07-01","from:elonmusk AI since:2023-07-01 until:2023-09-01","from:elonmusk AI since:2023-09-01 until:2023-12-01"],"sort": "Top","tweetLanguage": "en"}
2. Fetching Replies to a Specific Tweet with a Hashtag:
This example retrieves replies (in English, sorted by top) to a specific tweet (replace tweet_id_here with the
actual
tweet ID) that include a specific hashtag (replace hashtag_here).
{"includeSearchTerms": false,"onlyImage": false,"onlyQuote": false,"onlyTwitterBlue": false,"onlyVerifiedUsers": false,"onlyVideo": false,"searchTerms": ["conversation_id:tweet_id_here #hashtag_here"],"sort": "Latest","tweetLanguage": "en"}
Explanation of Key Input Fields:
searchTerms: This is the core of your query. You can use advanced search operators (as shown in the NASA example) or a conversation ID combined with a hashtag. Refer to the Advanced Search Guide for all the possibilities.sort: Choose "Latest" for chronological order or "Top" for the most relevant tweets.tweetLanguage: Specify the language code (e.g., "en" for English).only...(e.g.,onlyImage,onlyVerifiedUsers): Boolean flags (true/false) to filter for specific tweet characteristics.includeSearchTerms: Set to true if you want an extra field in the output showing which search term matched each tweet.
Getting Replies
A tweet URL or tweet ID needs scrapeReplies, which returns the tweets of its conversation, newest first. Without it the
tweet is skipped with a warning. Use the first tweet of the conversation, because replies belong to the conversation of
the first tweet. Write IDs as strings.
{"tweetIds": ["1630332507265589248"],"scrapeReplies": true,"maxItems": 100}
conversationIds does the same without scrapeReplies.
Monitoring New Tweets
Set onlyNewTweets and schedule the Actor. The first run returns tweets as usual and remembers them in a key-value store
named x-twitter-monitor-state in your account. Later runs return only tweets that were not returned before. Searches use
Latest order in this mode.
{"searchTerms": ["from:NASA"],"onlyNewTweets": true,"monitorName": "nasa","maxItems": 200}
- If the memory cannot be read, the run stops without returning or charging tweets.
- Up to 10,000 of the newest tweets are remembered per query.
- Use a different
monitorNamefor each schedule. Avoid running the same monitor twice at the same time.
Pricing
You pay for the events shown in the Pricing section of the Actor, and nothing else. There is no minimum charge per run.
start: once per run.result-item: for each tweet saved to the dataset. Duplicates within a query are not saved or charged.query(if shown in pricing): once for each query that successfully returned at least one page, even an empty one.
The Actor stops before it goes over the maximum cost or the maximum charged results you set. Results are not charged when the data cannot be loaded.
Good to Know
maxItemsis per query. Withsortset toBoth, it applies to Top and Latest separately, and tweets found by both are returned once.- Filters and dates apply to
searchTerms. An operator already written in a search term takes priority. - If a run is moved to another server, it continues where it stopped.
- If some queries fail, the others are still returned and a warning is logged. If all fail, the run fails.
- Respect Twitter's Terms of Service: Always use this tool ethically and responsibly.
Ethical Use and Data Practices
Our 'actor' operates without logging in to X.com. This means it does not implicitly accept any Terms of Service (ToS) that require a login, as we only process data that is publicly displayed and accessible to everyone without authentication.
We are fully committed to the principle of privacy by design and by default. All data collected explicitly excludes sensitive personal information or non-public data.
Furthermore, our actor runs on Apify, an EU-based company, which means our operations are designed to be compliant with relevant EU data protection regulations, including GDPR, where applicable. You can find more information about the legality of web scraping on Apify's blog: https://blog.apify.com/is-web-scraping-legal/
We have implemented robust technical measures to ensure the actor operates gently and does not impose an undue burden on X.com's servers. Our sole purpose is to facilitate responsible research and public data analysis, and we strictly prohibit any use that could cause harm to any party or the platform itself.
Custom Map Function
customMapFunction is plain, synchronous JavaScript that runs in a separate process. It receives a copy of each item and returns the
object to save. If it returns nothing, an array or a promise, throws, or takes too long, the original item is saved.
- Available: all JavaScript built-ins (
JSON,Math,Date,RegExp,Intl,Mapand so on) and simple versions ofconsole(prints nothing),URL(absolute URLs, read only),structuredClone(JSON values),atob,btoa,crypto.randomUUID()andperformance.now(). - Not available:
process,require, the wordimport,fetch, timers,Buffer,TextEncoder,TextDecoder,URLSearchParams,evalandnew Function.
Output Fields
Items keep the original tweet fields, with these additions:
| Field | Description |
|---|---|
viewCount | Number of views, or null when not available |
full_text_extended | Full text of long posts. full_text is unchanged |
author.is_blue_verified | Whether the author is a Premium (Blue) subscriber |
quote | The quoted tweet, with its own author |
Output Example
[{"id": "1630332507265589248","url": "https://x.com/NASA/status/1630332507265589248","twitterUrl": "https://twitter.com/NASA/status/1630332507265589248","full_text": "@yalhunzai We have internships open to international students from countries with whom we have agreements: https://t.co/Kl2Lz4qjpw","favorite_count": 14,"retweet_count": 9,"reply_count": 0,"quote_count": 0,"bookmark_count": 1,"viewCount": 1520,"author": {"id_str": "11348282","screen_name": "NASA","name": "NASA","advertiser_account_service_levels": ["dso","media_studio"],"advertiser_account_type": "promotable_user","analytics_type": "enabled","can_dm": false,"can_media_tag": true,"created_at": "Wed Dec 19 20:20:32 +0000 2007","description": "There's space for everybody. ✨\n\nVerification: https://t.co/8nok3NP4PW","entities": {"description": {"hashtags": [],"symbols": [],"urls": [{"display_url": "nasa.gov/socialmedia","expanded_url": "http://nasa.gov/socialmedia","indices": [46,69],"url": "https://t.co/8nok3NP4PW"}],"user_mentions": []},"url": {"urls": [{"display_url": "nasa.gov","expanded_url": "http://www.nasa.gov/","indices": [0,23],"url": "https://t.co/9NkQJKAnuU"}]}},"fast_followers_count": 0,"favourites_count": 16401,"followers_count": 85752559,"friends_count": 170,"geo_enabled": false,"has_custom_timelines": true,"has_extended_profile": true,"is_translator": false,"location": "Pale Blue Dot","media_count": 27374,"normal_followers_count": 85752559,"pinned_tweet_ids_str": [],"profile_background_color": "000000","profile_banner_url": "https://pbs.twimg.com/profile_banners/11348282/1718393721","profile_image_url_https": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg","profile_interstitial_type": "","profile_link_color": "205BA7","protected": false,"statuses_count": 72761,"translator_type_enum": "Regular","url": "https://t.co/9NkQJKAnuU","verified": false,"verified_type": "Government","withheld_in_countries": []},"bookmarked": false,"conversation_id_str": "1630332507265589248","created_at": "Tue Feb 28 20:28:53 +0000 2023","display_text_range": [11,130],"entities": {"hashtags": [],"symbols": [],"timestamps": [],"urls": [{"display_url": "go.nasa.gov/3EKfKkN","expanded_url": "https://go.nasa.gov/3EKfKkN","indices": [107,130],"url": "https://t.co/Kl2Lz4qjpw"}],"user_mentions": [{"id_str": "1583456964453040129","indices": [0,10],"name": "Baki bùlen","screen_name": "yalhunzai"}]},"favorited": false,"in_reply_to_screen_name": "yalhunzai","in_reply_to_status_id_str": "1630616311226048513","in_reply_to_user_id_str": "1583456964453040129","is_quote_status": false,"lang": "en","possibly_sensitive": false,"possibly_sensitive_editable": true,"retweeted": false,"user_id_str": "11348282"}]
Troubleshooting
If you encounter issues like too few results, no results, or incomplete tweet collection, refer to the detailed troubleshooting section in the Actor's input schema or documentation. Common causes include overly restrictive filters or exceeding rate limits.
Get Started
Start scraping Twitter data today! This Actor provides a powerful, flexible, and cost-effective solution for all your Twitter data extraction needs.