Guide
Twitter scraper: how to get public X data in 2026
Updated by the Handles API team
The four ways to scrape X (Twitter)
Four methods cover almost every project that needs public X data: open-source libraries, headless browser automation, the official X API and a data API. They differ mostly in who maintains the fragile part. The table compares them as of November 2026.
| Method | Setup | Account needed | Fragility | Cost | Scale | X terms |
|---|---|---|---|---|---|---|
| Open-source libraries (snscrape, twscrape) | Install a Python package | twscrape needs a pool of logged-in X accounts | High | Free software, plus accounts and proxies | Limited by the rate limits of each account | Scraping prohibited without written consent |
| Headless browser (Playwright, Puppeteer) | Write and host a browser script | Usually a logged-in session | High | Compute, proxies and your maintenance time | Slow, one page at a time per browser | Scraping prohibited without written consent |
| Official X API | Developer app at console.x.com, bearer token | A developer app | Low | $0.005 per post read, $0.010 per user read | Rate limits and a 3 million post reads monthly cap | The route X sanctions |
| Data API (Handles API) | One API key, plain HTTP requests | None of your own X accounts | Low on your side, the provider maintains it | Credits, plans from $29 a month | Plan credits and a per-minute rate limit | Independent service, your own use stays your responsibility |
Read the table by fragility and account needs first, and by price second. A free library that needs twenty logged-in accounts and a proxy pool is not free, and an official API with a clear per-read price is easy to budget. Scale is the last column to check, because every method hits a ceiling somewhere: account limits, browser capacity, a monthly cap or your plan credits.
Open-source scrapers and headless browsers
snscrape and twscrape are free Python tools, and both depend on how X serves its pages to a visitor. Their behavior changes when X changes, and this page does not track project versions or popularity.
snscrape
snscrape's X module has mostly stopped working since X began requiring a login in 2023, and users widely report that. Check the project repository for its current status before you depend on it.
twscrape
twscrape asks for a pool of logged-in X accounts. The accounts can be suspended, so a working setup needs a steady supply of fresh accounts, and each one is a login you hold and must look after.
Playwright and Puppeteer
A headless browser loads X the way a person would and reads the rendered page. It is the most flexible method and the most expensive to run: you host browsers, manage sessions, and rewrite selectors when the page changes. X can also block automated sessions, and most pages sit behind a login.
Why X scrapers break
X scrapers break because the data sits behind a login wall, strict rate limits and internal endpoints that change without notice. Four failure modes account for most of the pain.
- Login wall. Since 2023 most pages and searches ask for a login, so a scraper that worked logged out stops returning data.
- Rate limits. Each account and each IP can make only so many requests in a window. Past it you get errors or empty pages, and heavy use invites a suspension.
- doc_id and GraphQL changes. X's web app calls internal GraphQL queries identified by IDs, often called doc_id values. Scraper authors describe them as changing when X ships a new web build, which breaks any scraper that hard-codes one.
- Account suspension. Libraries that log in with X accounts lose those accounts when X flags them, and the scraper loses capacity with them.
None of these is a bug you can fix once. They are the normal cost of reading a site that does not offer you a stable interface.
What X's terms say about scraping
X's Terms of Service state that “crawling or scraping the Services in any form, for any purpose without our prior written consent is expressly prohibited” (X Terms of Service). Whether a breach of terms creates legal liability is a separate question that courts have answered differently depending on the facts.
Using an API moves the collection off your servers, it does not remove your own obligations under GDPR or similar laws. The cases, the regulators' statements and the platform terms are covered in Is web scraping legal?
Scrape X with an API
To read public X data without running a scraper, send a GET request to https://api.handlesapi.com/v1 with your key as a bearer token. The catalog holds about 33.0M X accounts, and a profile lookup from it costs 1 credit and answers in milliseconds.
curl "https://api.handlesapi.com/v1/directory/x/nasa" \
-H "Authorization: Bearer $HANDLES_API_KEY"const res = await fetch("https://api.handlesapi.com/v1/directory/x/nasa", {
headers: { Authorization: `Bearer ${process.env.HANDLES_API_KEY}` },
});
const { data, meta } = await res.json();import os
import requests
res = requests.get(
"https://api.handlesapi.com/v1/directory/x/nasa",
headers={"Authorization": f"Bearer {os.environ['HANDLES_API_KEY']}"},
timeout=30,
)
body = res.json(){
"data": {
"platform": "x",
"object": "account",
"record": {
"username": "NASA",
"name": "NASA",
"followers_count": 92086821,
"following_count": 115,
"statuses_count": 74588,
"is_blue_verified": true,
"verified_type": "Government",
"account_created_at": "2007-12-19 20:20:32+00",
"language": "en",
"category": "science",
"tier": "S",
"last_seen": "2026-11-26 13:29:22.316073+00"
}
},
"meta": {
"source": "catalog",
"request_id": "req_f6d829b59d0d8864",
"generated_at": "2026-11-26T13:54:37.167Z",
"took_ms": 56
}
}Real response from the live API, captured Nov 26, 2026. 16 more record fields trimmed for space. Long strings and arrays are shortened.
The same key reads more than profiles. Live endpoints cover timelines, mentions, replies, quote posts, followers, lists, communities and trends, and catalog endpoints add engagement medians and a benchmark against accounts of similar size. The X follower graph is partial: it holds follow edges only between accounts already in the catalog.
Search and timelines (live reads)
The search endpoint accepts X's advanced search syntax as it is: from:, to:, since:, until:, filter:, min_faves: and lang:. This request returns posts from one account that have at least 1,000 likes. Responses use the standard { data, meta } envelope, and meta.page.next_cursor pages through results until it is null. The reference page is GET /v1/x/search/tweets.
curl "https://api.handlesapi.com/v1/x/search/tweets?query=from:nasa%20min_faves:1000&limit=20" \
-H "Authorization: Bearer $HANDLES_API_KEY"const res = await fetch("https://api.handlesapi.com/v1/x/search/tweets?query=from:nasa%20min_faves:1000&limit=20", {
headers: { Authorization: `Bearer ${process.env.HANDLES_API_KEY}` },
});
const { data, meta } = await res.json();import os
import requests
res = requests.get(
"https://api.handlesapi.com/v1/x/search/tweets?query=from:nasa%20min_faves:1000&limit=20",
headers={"Authorization": f"Bearer {os.environ['HANDLES_API_KEY']}"},
timeout=30,
)
body = res.json()A timeline read returns the latest posts of an account with counts for likes, reposts, replies, quotes and views.
curl "https://api.handlesapi.com/v1/x/users/nasa/tweets?limit=2" \
-H "Authorization: Bearer $HANDLES_API_KEY"const res = await fetch("https://api.handlesapi.com/v1/x/users/nasa/tweets?limit=2", {
headers: { Authorization: `Bearer ${process.env.HANDLES_API_KEY}` },
});
const { data, meta } = await res.json();import os
import requests
res = requests.get(
"https://api.handlesapi.com/v1/x/users/nasa/tweets?limit=2",
headers={"Authorization": f"Bearer {os.environ['HANDLES_API_KEY']}"},
timeout=30,
)
body = res.json(){
"data": {
"tweets": [
{
"tweet_id": "2125915027819446402",
"url": "https://x.com/NASA/status/2125915027819446402",
"text": "LIVE: Watch the Progress 97 spacecraft arrive and dock to the @space_station after a two-day trip...",
"created_at": "2026-11-26T11:30:14+00:00",
"lang": "en",
"source": null,
"likes": 833,
"retweets": 151,
"replies": 73,
"quotes": 16,
"bookmarks": 50,
"views": 276360,
"is_reply": false,
"is_retweet": false,
"is_quote": false,
"conversation_id": "2125915027819446402",
"in_reply_to_tweet_id": null,
"quoted_tweet_id": null,
"retweeted_tweet_id": null,
"hashtags": [],
"mentions": [
"Space_Station"
],
"links": [
"https://x.com/i/broadcasts/2onVBonVMMWjaV"
],
"media": [],
"author": {
"user_id": "11348282",
"handle": "NASA",
"display_name": "NASA",
"bio": "Making the seemingly impossible, possible. ✨",
"followers": 92086892,
"following": 115,
"tweets": 74588,
"media_count": 28267,
"likes_given": 17125,
"is_verified": false,
"is_blue_verified": true,
"is_protected": false,
"location": "Pale Blue Dot",
"avatar_url": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_400x400.jpg",
"header_url": "https://pbs.twimg.com/profile_banners/11348282/1788992290",
"created_at": "2007-12-19T20:20:32+00:00",
"profile_url": "https://x.com/NASA"
}
}
],
"has_next_page": false
},
"meta": {
"page": {
"limit": 2,
"next_cursor": null,
"count": 2
},
"source": "live:xlookup",
"request_id": "req_503bc38c7610cc00",
"generated_at": "2026-11-26T13:54:58.874Z",
"took_ms": 1696
}
}Real response from the live API, captured Nov 26, 2026. Long strings and arrays are shortened.
scrape:live scope. It is a sensitive scope that keys do not get by default, and calls made with it are audited; see authentication. Live reads take between 2 and 25 seconds and can return 503 at busy moments, so set a 30 second timeout and retry on 503.Every live and catalog X endpoint is listed in the API reference, and the X API page summarizes what the API reads. To check how many of an account's followers look real, try the free fake follower checker.
What it costs compared with the official API
On every Handles API plan a catalog read costs 1 credit and a live read costs 2 credits. The table converts each paid plan into a price for 1,000 reads.
| Plan | Monthly price | Credits | 1,000 catalog reads | 1,000 live reads |
|---|---|---|---|---|
| Handles API Starter | $29 | 15,000 | $1.93 | $3.87 |
| Handles API Pro | $99 | 75,000 | $1.32 | $2.64 |
| Handles API Business | $299 | 300,000 | $1.00 | $1.99 |
| Handles API Scale | $799 | 1,200,000 | $0.67 | $1.33 |
The official X API charges $0.005 per post read and $0.010 per user read, which is $5 and $10 per 1,000, as of November 2026 (X API pricing). Which route is cheaper depends on your plan size and on whether you need catalog or live reads. The full breakdown, including rate limits and what is still free, is in X API pricing in 2026.
Which method to pick
Choose by what you can afford to maintain, not by what costs nothing on day one. A scraper has no invoice but it has an owner who fixes it.
- Pick the official X API when you need to post, read direct messages, or act for users who authorize your app.
- Pick a data API when you want public profiles, posts and search as JSON without managing accounts. Brand monitoring is the common case, covered in social listening.
- Pick libraries or a browser only for a small one-off job where breakage costs you little and you accept the terms risk.
- For other networks, social media scraping across platforms compares the same four methods per platform.
Start with the free trial of 100 credits, no card, and compare the JSON against what your scraper returns today. Plans are on the pricing page.
Frequently asked questions
Does snscrape still work for Twitter?
What does twscrape need to run?
Is it legal to scrape Twitter?
Can I scrape Twitter without logging in?
What is the cheapest way to get Twitter data?
Can I search tweets by keyword through the API?
Try it on your own handles
The free trial gives you 100 credits for every endpoint, once, with no card. Paid plans start at $29 a month.