DEV Community

agenthustler
agenthustler

Posted on

How to Scrape Twitter/X in 2026 (Without Getting Rate-Limited)

Twitter's API pricing keeps climbing. As of 2026, the cheapest tier with meaningful access costs $100/month — and even that comes with strict rate limits. For developers who just need tweet data for analytics, research, or monitoring, that's a tough pill to swallow.

So what are your actual options for scraping Twitter/X data in 2026? Let's break down the three main approaches, with real code you can run today.

Looking for a ready-to-use solution? Try the Twitter Scraper on Apify — handles authentication, proxies, and rate limits out of the box.


Option 1: The Official X/Twitter API

The official API is the "blessed" path. You sign up at developer.x.com, get your keys, and use a library like tweepy.

The catch: The free tier gives you 1,500 tweets/month for posting only — no search. The Basic tier ($100/mo) gives you 10,000 tweets/month for search. The Pro tier ($5,000/mo) gives you 1M tweets/month.

For most side projects, dashboards, or research tasks, $100/month for 10K tweets is hard to justify.

import tweepy

client = tweepy.Client(bearer_token="YOUR_BEARER_TOKEN")

# Basic tier: 10,000 tweets/month cap
response = client.search_recent_tweets(
    query="python webscraping",
    max_results=10,
    tweet_fields=["created_at", "public_metrics"]
)

for tweet in response.data:
    print(tweet.text)
Enter fullscreen mode Exit fullscreen mode

Pros: Stable, well-documented, legal clarity.
Cons: Expensive, strict rate limits, limited historical access on lower tiers.


Option 2: Build Your Own Scraper

You could reverse-engineer Twitter's internal API or use browser automation (Playwright, Puppeteer) to extract data. Some developers go this route to avoid the API costs.

The reality: Twitter has aggressive anti-bot measures in 2026. IP fingerprinting, CAPTCHAs, session tokens that rotate — you'll spend more time maintaining your scraper than using the data it collects.

I've seen teams burn 40+ hours building a custom Twitter scraper, only to have it break within two weeks when Twitter ships an update.


Option 3: Use a Ready-Made Scraper (The Practical Choice)

This is what I actually recommend for most developers. Platforms like Apify host pre-built scrapers (called "actors") that handle all the hard parts — proxy rotation, rate limit management, session handling, and data formatting.

Here's how you'd scrape tweets about a topic using the Twitter Scraper actor on Apify:

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {
    "searchTerms": ["python webscraping"],
    "maxTweets": 100,
    "sort": "Latest",
}

run = client.actor("cryptosignals/twitter-scraper").call(run_input=run_input)

# Grab the results
for tweet in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"@{tweet['author']['userName']}: {tweet['text']}")
    print(f"  Likes: {tweet['likeCount']} | Retweets: {tweet['retweetCount']}")
    print()
Enter fullscreen mode Exit fullscreen mode

That's it. No proxy setup, no session management, no fighting CAPTCHAs. The actor handles all of that behind the scenes.

You get structured JSON output with full tweet metadata: author info, engagement metrics, timestamps, media URLs, and reply threads.


Comparison: All Three Approaches

Official API (Basic) DIY Scraper Apify Actor
Monthly cost $100 fixed $20-50 (proxies) Pay per use (~$5 for 10K tweets)
Setup time 30 min 20-40 hours 5 min
Maintenance None Constant (breaks often) None (maintained by author)
Rate limit handling Built-in (strict caps) Manual (error-prone) Built-in (automatic retries)
Historical data Limited on Basic tier Depends on implementation Full access
Data format JSON (limited fields) Whatever you build Rich structured JSON
Reliability High Low (Twitter fights you) High

When to Use Which

Use the Official API if:

  • You need guaranteed uptime and SLA
  • Your company has the budget
  • You only need a small volume of tweets

Build your own if:

  • You enjoy pain (kidding — sort of)
  • You have very specific requirements that no existing tool covers
  • You want to learn about web scraping internals

Use a ready-made actor if:

  • You want data quickly without infrastructure headaches
  • You're cost-sensitive
  • You need more volume than the API allows at a reasonable price

Getting Started

  1. Create a free Apify account
  2. Install the client: pip install apify-client
  3. Run the code above with your token
  4. Get structured tweet data in minutes

The Twitter Scraper actor supports search by keyword, hashtag, user profile, and URL. You can configure output format, date ranges, and engagement thresholds.

Try the Twitter Scraper on Apify →


Have questions about scraping Twitter data? Drop them in the comments — I'll answer what I can.

Top comments (0)