Handles API

Guide

Twitter scraper: how to get public X data in 2026

There are four ways to scrape Twitter (X) in 2026: open-source libraries such as snscrape and twscrape, headless browsers such as Playwright, the official X API, and a data API. The first two are free to start but break often and need accounts. The last two are stable and metered.

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.

MethodSetupAccount neededFragilityCostScaleX terms
Open-source libraries (snscrape, twscrape)Install a Python packagetwscrape needs a pool of logged-in X accountsHighFree software, plus accounts and proxiesLimited by the rate limits of each accountScraping prohibited without written consent
Headless browser (Playwright, Puppeteer)Write and host a browser scriptUsually a logged-in sessionHighCompute, proxies and your maintenance timeSlow, one page at a time per browserScraping prohibited without written consent
Official X APIDeveloper app at console.x.com, bearer tokenA developer appLow$0.005 per post read, $0.010 per user readRate limits and a 3 million post reads monthly capThe route X sanctions
Data API (Handles API)One API key, plain HTTP requestsNone of your own X accountsLow on your side, the provider maintains itCredits, plans from $29 a monthPlan credits and a per-minute rate limitIndependent service, your own use stays your responsibility
Official prices and limits: X API pricing and X API rate limits, as of November 2026. Terms: X Terms of Service.

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?

This page is general information, not legal advice. Laws differ by country; talk to a lawyer about your own project.

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"
200 OK309 ms · 1 credit
{
  "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.

Request (curl)
curl "https://api.handlesapi.com/v1/x/search/tweets?query=from:nasa%20min_faves:1000&limit=20" \
  -H "Authorization: Bearer $HANDLES_API_KEY"
Request (Node)
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();
Request (Python)
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"
200 OK1788 ms · 2 credits
{
  "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.

Live X endpoints need the 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.

PlanMonthly priceCredits1,000 catalog reads1,000 live reads
Handles API Starter$2915,000$1.93$3.87
Handles API Pro$9975,000$1.32$2.64
Handles API Business$299300,000$1.00$1.99
Handles API Scale$7991,200,000$0.67$1.33
Plan price divided by included credits. A catalog read costs 1 credit, a live read 2 credits. The Free trial is 100 credits once, no card.

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?
Users widely report that snscrape's X module mostly stopped working after X began requiring a login in 2023. The project is open source, so check its repository for the current state before building on it. If you need a stable feed of public X data, a data API or the official API does not depend on a logged-out web path.
What does twscrape need to run?
twscrape works by logging in with X accounts, so you need a pool of logged-in X accounts and you must keep them healthy. Accounts can be suspended, which removes them from the pool and stops requests. Plan for account supply, proxies and replacement as part of the real cost of the library.
Is it legal to scrape Twitter?
There is no single answer. US courts have treated unauthorized-access law and contract claims as separate questions, and X's Terms of Service prohibit scraping without written consent. Data protection law can also apply to public personal data. This is general information, not legal advice; ask a lawyer about your own project.
Can I scrape Twitter without logging in?
Most X pages and searches now require a login, so logged-out scrapers get little. A data API reads public X data with a key instead of your own X account, so there is no login or session for you to maintain and nothing to lose if an account is suspended.
What is the cheapest way to get Twitter data?
For a few hundred reads, a free trial is cheapest: the Free plan gives 100 credits once with no card. For steady volume, compare the cost per 1,000 reads in the table on this page with the official pay-per-use prices, and add the engineering time a scraper needs.
Can I search tweets by keyword through the API?
Yes. The search endpoint passes X's advanced search syntax through unchanged, so from:, since:, until:, lang: and min_faves: all work. It is a live read that costs 2 credits per call, takes between 2 and 25 seconds, and needs the scrape:live scope on your key.