twscrape
Python library for scraping Twitter/X data using GraphQL API with account rotation and session management. Use when extracting tweets, user profiles, followers, trends, or building social media monitoring tools.
What this skill does
# twscrape
Python library for scraping Twitter/X data using GraphQL API with account rotation and session management.
## When to use this skill
Use this skill when:
- Working with Twitter/X data extraction and scraping
- Need to bypass Twitter API limitations with account rotation
- Building social media monitoring or analytics tools
- Extracting tweets, user profiles, followers, trends from Twitter/X
- Need async/parallel scraping operations for large-scale data collection
- Looking for alternatives to official Twitter API
## Quick Reference
### Installation
```bash
pip install twscrape
```
### Basic Setup
```python
import asyncio
from twscrape import API, gather
async def main():
api = API() # Uses accounts.db by default
# Add accounts (with cookies - more stable)
cookies = "abc=12; ct0=xyz"
await api.pool.add_account("user1", "pass1", "[email protected]", "mail_pass", cookies=cookies)
# Or add accounts (with login/password - less stable)
await api.pool.add_account("user2", "pass2", "[email protected]", "mail_pass2")
await api.pool.login_all()
asyncio.run(main())
```
### Common Operations
```python
# Search tweets
await gather(api.search("elon musk", limit=20))
# Get user info
await api.user_by_login("xdevelopers")
user = await api.user_by_id(2244994945)
# Get user tweets
await gather(api.user_tweets(user_id, limit=20))
await gather(api.user_tweets_and_replies(user_id, limit=20))
await gather(api.user_media(user_id, limit=20))
# Get followers/following
await gather(api.followers(user_id, limit=20))
await gather(api.following(user_id, limit=20))
# Tweet operations
await api.tweet_details(tweet_id)
await gather(api.retweeters(tweet_id, limit=20))
await gather(api.tweet_replies(tweet_id, limit=20))
# Trends
await gather(api.trends("news"))
```
## Key Features
### 1. Multiple API Support
- **Search API**: Standard Twitter search functionality
- **GraphQL API**: Advanced queries and data extraction
- **Automatic switching**: Based on rate limits and availability
### 2. Async/Await Architecture
```python
# Parallel scraping
async for tweet in api.search("elon musk"):
print(tweet.id, tweet.user.username, tweet.rawContent)
```
### 3. Account Management
- Add multiple accounts for rotation
- Automatic rate limit handling
- Session persistence across runs
- Email verification support (IMAP or manual)
### 4. Data Models
- SNScrape-compatible models
- Easy conversion to dict/JSON
- Raw API response access available
## Core API Methods
### Search Operations
#### `search(query, limit, kv={})`
Search tweets by query string.
**Parameters:**
- `query` (str): Search query (supports Twitter search syntax)
- `limit` (int): Maximum number of tweets to return
- `kv` (dict): Additional parameters (e.g., `{"product": "Top"}` for Top tweets)
**Returns:** AsyncIterator of Tweet objects
**Example:**
```python
# Latest tweets
async for tweet in api.search("elon musk", limit=20):
print(tweet.rawContent)
# Top tweets
await gather(api.search("python", limit=20, kv={"product": "Top"}))
```
### User Operations
#### `user_by_login(username)`
Get user information by username.
**Example:**
```python
user = await api.user_by_login("xdevelopers")
print(user.id, user.displayname, user.followersCount)
```
#### `user_by_id(user_id)`
Get user information by user ID.
#### `followers(user_id, limit)`
Get user's followers.
#### `following(user_id, limit)`
Get users that the user follows.
#### `verified_followers(user_id, limit)`
Get only verified followers.
#### `subscriptions(user_id, limit)`
Get user's Twitter Blue subscriptions.
### Tweet Operations
#### `tweet_details(tweet_id)`
Get detailed information about a specific tweet.
#### `tweet_replies(tweet_id, limit)`
Get replies to a tweet.
#### `retweeters(tweet_id, limit)`
Get users who retweeted a specific tweet.
#### `user_tweets(user_id, limit)`
Get tweets from a user (excludes replies).
#### `user_tweets_and_replies(user_id, limit)`
Get tweets and replies from a user.
#### `user_media(user_id, limit)`
Get tweets with media from a user.
### Other Operations
#### `list_timeline(list_id)`
Get tweets from a Twitter list.
#### `trends(category)`
Get trending topics by category.
**Categories:** "news", "sport", "entertainment", etc.
## Account Management
### Adding Accounts
**With cookies (recommended):**
```python
cookies = "abc=12; ct0=xyz" # String or JSON format
await api.pool.add_account("user", "pass", "[email protected]", "mail_pass", cookies=cookies)
```
**With credentials:**
```python
await api.pool.add_account("user", "pass", "[email protected]", "mail_pass")
await api.pool.login_all()
```
### CLI Account Management
```bash
# Add accounts from file
twscrape add_accounts accounts.txt username:password:email:email_password
# Login all accounts
twscrape login_accounts
# Manual email verification
twscrape login_accounts --manual
# List accounts and status
twscrape accounts
# Re-login specific accounts
twscrape relogin user1 user2
# Retry failed logins
twscrape relogin_failed
```
## Proxy Configuration
### Per-Account Proxy
```python
proxy = "http://login:[email protected]:8080"
await api.pool.add_account("user", "pass", "[email protected]", "mail_pass", proxy=proxy)
```
### Global Proxy
```python
api = API(proxy="http://login:[email protected]:8080")
```
### Environment Variable
```bash
export TWS_PROXY=socks5://user:[email protected]:1080
twscrape search "elon musk"
```
### Dynamic Proxy Changes
```python
api.proxy = "socks5://user:[email protected]:1080"
doc = await api.user_by_login("elonmusk")
api.proxy = None # Disable proxy
```
**Priority:** `api.proxy` > `TWS_PROXY` env var > account-specific proxy
## CLI Usage
### Search Operations
```bash
twscrape search "QUERY" --limit=20
twscrape search "elon musk lang:es" --limit=20 > data.txt
twscrape search "python" --limit=20 --raw # Raw API responses
```
### User Operations
```bash
twscrape user_by_login USERNAME
twscrape user_by_id USER_ID
twscrape followers USER_ID --limit=20
twscrape following USER_ID --limit=20
twscrape verified_followers USER_ID --limit=20
twscrape user_tweets USER_ID --limit=20
```
### Tweet Operations
```bash
twscrape tweet_details TWEET_ID
twscrape tweet_replies TWEET_ID --limit=20
twscrape retweeters TWEET_ID --limit=20
```
### Trends
```bash
twscrape trends sport
twscrape trends news
```
### Custom Database
```bash
twscrape --db custom-accounts.db <command>
```
## Advanced Usage
### Raw API Responses
```python
async for response in api.search_raw("elon musk"):
print(response.status_code, response.json())
```
### Stopping Iteration
```python
from contextlib import aclosing
async with aclosing(api.search("elon musk")) as gen:
async for tweet in gen:
if tweet.id < 200:
break
```
### Convert Models to Dict/JSON
```python
user = await api.user_by_id(user_id)
user_dict = user.dict()
user_json = user.json()
```
### Enable Debug Logging
```python
from twscrape.logger import set_log_level
set_log_level("DEBUG")
```
## Environment Variables
- **`TWS_PROXY`**: Global proxy for all accounts
Example: `socks5://user:[email protected]:1080`
- **`TWS_WAIT_EMAIL_CODE`**: Timeout for email verification (default: 30 seconds)
- **`TWS_RAISE_WHEN_NO_ACCOUNT`**: Raise exception when no accounts available instead of waiting
Values: `false`, `0`, `true`, `1` (default: `false`)
## Rate Limits & Limitations
### Rate Limits
- Rate limits reset **every 15 minutes** per endpoint
- Each account has **separate limits** for different operations
- Accounts automatically rotate when limits are reached
### Tweet Limits
- `user_tweets` and `user_tweets_and_replies` return approximately **3,200 tweets maximum** per user
- This is a Twitter/X platform limitation
### Account Status
- Rate limits vary based on:
- Account age
- Account verification status
- Account activity history
### Handling Rate Limits
The library automatically:
- Switches Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.