twscrape
Twitter GraphQL and Search API implementation with SNScrape data models
Decision gist · record as of 2026-08-14
Yes, if you need to scrape X/Twitter data at scale and can manage authorized account credentials responsibly. The library is actively maintained, has low install friction, uses a permissive MIT license, and offers both programmatic and CLI interfaces. Main considerations: you must provide your own account cookies (no API key), and X's Terms of Service discourage multi-account use—deploy with awareness of platform policy and your own risk tolerance.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Needs authorized X/Twitter account credentials (auth_token and ct0 cookies from x.com).
- Low install friction: pure Python wheel with 7 runtime dependencies (aiosqlite, beautifulsoup4, fake-useragent, httpx, loguru, py-machineid, pyotp).
License · maintenance · safety
MIT (permissive) — MIT license (permissive): you can use, modify, and distribute twscrape freely in commercial and private projects with minimal restrictions, provided you retain the license notice.
last release 2026-08-07 (7 days) · last repo commit 2026-08-07 · 2,679 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 132,475 downloads/mo, #11,550 on PyPI
Alternatives
Verify before relying
pip install twscrape
import asyncio
from twscrape import API
async def main():
api = API()
await api.pool.add_account_cookies("my_account", "auth_token=xxx; ct0=yyy")
user = await api.user_by_login("xdevelopers")
print(user.id, user.username, user.followersCount)
asyncio.run(main())- Whether the optional curl-cffi backend (TWS_HTTP_BACKEND=curl) is necessary for avoiding detection or if httpx alone is sufficient for most use cases.
- Rate-limit behavior and account rotation strategy when multiple accounts are exhausted simultaneously.
- Whether X/Twitter's Terms of Service enforcement against multi-account scraping poses practical risk to users of this library.
What it is and what it does
twscrape is an async Python library that wraps X/Twitter's GraphQL and Search APIs by rotating through a pool of your own authorized accounts. It stores session cookies in SQLite, automatically switches accounts when rate-limited, and returns either parsed Tweet/User/Trend objects (compatible with SNScrape's data model) or raw API responses. The library includes both a Python API for concurrent scraping and a CLI for one-off queries.
You add accounts via browser cookies (the most stable method), and twscrape handles session persistence, per-account proxies, and the mechanics of keeping your scraper running across rate limits. It supports search with product filters (Latest, Top, Media), tweet threads and replies, user timelines, followers, lists, communities, and trends. The async/await design lets you run multiple concurrent scrapers efficiently.
Use it for
- Bulk collection of tweets matching a search query or from specific users for research or analysis.
- Monitoring trending topics or specific accounts over time with automatic account rotation to avoid rate limits.
- Building a dataset of user metadata, follower networks, or community membership for social network analysis.
- Extracting tweet threads and conversation context programmatically for NLP or sentiment analysis pipelines.
- Running scheduled scraping jobs via CLI that output JSON Lines for downstream processing or storage.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to scrape X/Twitter data at scale and can manage authorized account credentials responsibly.
The library is actively maintained, has low install friction, uses a permissive MIT license, and offers both programmatic and CLI interfaces. Main considerations: you must provide your own account cookies (no API key), and X's Terms of Service discourage multi-account use—deploy with awareness of platform policy and your own risk tolerance.
Install
twscrape on PyPI
Before you install
Low install friction: pure Python wheel with 7 runtime dependencies (aiosqlite, beautifulsoup4, fake-useragent, httpx, loguru, py-machineid, pyotp). Actively maintained—last commit 2026-08-07, released 0.20.0 seven days ago, 2679 GitHub stars.
Requires Python 3.10 or later. Needs authorized X/Twitter account credentials (auth_token and ct0 cookies from x.com).
License in practice
MIT license (permissive): you can use, modify, and distribute twscrape freely in commercial and private projects with minimal restrictions, provided you retain the license notice.
Quickstart
pip install twscrape
import asyncio
from twscrape import API
async def main():
api = API()
await api.pool.add_account_cookies("my_account", "auth_token=xxx; ct0=yyy")
user = await api.user_by_login("xdevelopers")
print(user.id, user.username, user.followersCount)
asyncio.run(main())
Verify before relying
- Whether the optional curl-cffi backend (TWS_HTTP_BACKEND=curl) is necessary for avoiding detection or if httpx alone is sufficient for most use cases.
- Rate-limit behavior and account rotation strategy when multiple accounts are exhausted simultaneously.
- Whether X/Twitter's Terms of Service enforcement against multi-account scraping poses practical risk to users of this library.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 7 packagesaiosqlitebeautifulsoup4fake-useragenthttpxlogurupy-machineidpyotp |
| Maintenance | Actively maintained 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 132,475 / month, #11,550 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14 |
Evidence: twscrape-0.20.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “account pool rotation”
- twscrapetwscrape is an async Python library and CLI for querying X/Twitter's…
- azure-mgmt-batchProvides a Python client library for managing Azure Batch…
- iaqualinkAsynchronous Python library for monitoring and controlling Jandy…
Give your agent the search over MCP, or paste the wish link into any chat.
More WWW/HTTP packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
HTTPX is a fully featured HTTP client library for Python that provides both sync and async APIs, with support for HTTP/1.1 and HTTP/2, plus an integrated command-line client.
Install it if you are building new projects or modernizing existing ones that rely on HTTP.
A minimal low-level HTTP client library that sends HTTP requests with thread-safe and task-safe connection pooling, supporting HTTP/1.1, HTTP/2, proxies, and both sync and async interfaces.
aiohttp is an async HTTP client and server framework built on asyncio, supporting both WebSockets and middleware-based routing for building concurrent web applications.
Install it if you need async HTTP client or server capabilities in asyncio-based applications.
See also Scweet · tweepy · twikit · twython · python-graphql-client · snscrape · xclienttransaction · python-twitter · graphqlclient · crowdin-api-client