66[ ![ PyPI version] ( https://img.shields.io/pypi/v/x_twitter_scraper.svg?label=pypi%20(stable) )] ( https://pypi.org/project/x_twitter_scraper/ )
77
88Use the Xquik Python SDK for Twitter search, timelines, profiles & followers.
9- Manage media, webhooks & X automation with sync or async clients.
10- It provides a Twitter API alternative through documented Xquik REST routes.
9+ Manage media, webhooks & X automation through documented Xquik REST routes.
1110
1211[ Python SDK Guide] ( https://docs.xquik.com/sdks/python ) | [ API Map] ( api.md ) | [ REST API] ( https://docs.xquik.com/api-reference/overview ) | [ Webhooks] ( https://docs.xquik.com/api-reference/webhooks/create ) | [ MCP Guide] ( https://docs.xquik.com/mcp/overview )
1312
1413[ Stainless] ( https://www.stainless.com/ ) generates this SDK.
1514
1615## Common Twitter & X Tasks
1716
18- Map each task to its REST route.
19-
2017| Task | REST Route | Usage |
2118| --- | --- | --- |
2219| Search tweets without the X API | ` GET /x/tweets/search ` | Use keyword or advanced operator queries. |
@@ -25,6 +22,7 @@ Map each task to its REST route.
2522| Scrape following accounts | ` GET /x/users/{id}/following ` | Use an extraction for complete datasets. |
2623| Read a home timeline | ` GET /x/timeline ` | Approve this private read. |
2724| Export large X datasets | ` POST /extractions ` | Poll status, then download results. |
25+ | Run giveaway draws | ` POST /draws ` | Pick winners from post replies. |
2826| Download or upload media | ` /x/media/* ` | Use typed file helpers. |
2927| Monitor an account | ` POST /monitors ` | Deliver events through HMAC webhooks. |
3028| Post or reply | ` POST /x/tweets ` | Confirm the account and payload. |
@@ -34,10 +32,6 @@ Map each task to its REST route.
3432Use the typed REST SDK in application code. Add ` https://xquik.com/mcp ` to MCP clients.
3533Follow the [ MCP guide] ( https://docs.xquik.com/mcp/overview ) for current authentication support.
3634
37- ## Giveaway Draws & Extractions
38-
39- Run giveaway draws and export extraction results from Python pipelines.
40-
4135## Package & Registry Trust
4236
4337- Package: [ PyPI ` x_twitter_scraper ` ] ( https://pypi.org/project/x_twitter_scraper/ )
@@ -49,7 +43,6 @@ Run giveaway draws and export extraction results from Python pipelines.
4943## Installation
5044
5145``` sh
52- # Install from PyPI.
5346pip install x_twitter_scraper
5447```
5548
@@ -62,7 +55,7 @@ import os
6255from x_twitter_scraper import XTwitterScraper
6356
6457client = XTwitterScraper(
65- api_key = os.environ.get(" X_TWITTER_SCRAPER_API_KEY" ), # This is the default and can be omitted
58+ api_key = os.environ.get(" X_TWITTER_SCRAPER_API_KEY" ), # Optional; the client reads this variable.
6659)
6760
6861response = client.x.tweets.search(
@@ -84,7 +77,7 @@ import asyncio
8477from x_twitter_scraper import AsyncXTwitterScraper
8578
8679client = AsyncXTwitterScraper(
87- api_key = os.environ.get(" X_TWITTER_SCRAPER_API_KEY" ), # This is the default and can be omitted
80+ api_key = os.environ.get(" X_TWITTER_SCRAPER_API_KEY" ), # Optional; the client reads this variable.
8881)
8982
9083
@@ -105,7 +98,6 @@ Both clients expose the same resources and methods.
10598The async client uses ` httpx ` . Install ` aiohttp ` for an alternative backend:
10699
107100``` sh
108- # Install from PyPI.
109101pip install x_twitter_scraper[aiohttp]
110102```
111103
@@ -120,7 +112,7 @@ from x_twitter_scraper import AsyncXTwitterScraper
120112
121113async def main () -> None :
122114 async with AsyncXTwitterScraper(
123- api_key = os.environ.get(" X_TWITTER_SCRAPER_API_KEY" ), # This is the default and can be omitted
115+ api_key = os.environ.get(" X_TWITTER_SCRAPER_API_KEY" ), # Optional; the client reads this variable.
124116 http_client = DefaultAioHttpClient(),
125117 ) as client:
126118 response = await client.x.tweets.search(
@@ -140,7 +132,6 @@ Responses use [Pydantic models](https://docs.pydantic.dev) with these helpers:
140132- Serialize to JSON with ` model.to_json() ` .
141133- Convert to a dictionary with ` model.to_dict() ` .
142134
143- Typed requests and responses provide editor completion and documentation.
144135Set ` python.analysis.typeCheckingMode ` to ` basic ` in VS Code to catch type errors.
145136
146137## File Uploads
@@ -184,7 +175,7 @@ except x_twitter_scraper.APIConnectionError as e:
184175except x_twitter_scraper.RateLimitError as e:
185176 print (" Rate limited. Retry later." )
186177except x_twitter_scraper.APIStatusError as e:
187- print (" The server returned another non-2xx status." )
178+ print (" Server returned a non-2xx status." )
188179 print (e.status_code)
189180 print (e.response)
190181```
@@ -214,7 +205,6 @@ from x_twitter_scraper import XTwitterScraper
214205
215206# Set the client default:
216207client = XTwitterScraper(
217- # default is 2
218208 max_retries = 0 ,
219209)
220210
@@ -235,7 +225,7 @@ from x_twitter_scraper import XTwitterScraper
235225
236226# Set the client default:
237227client = XTwitterScraper(
238- # 20 seconds ( default is 1 minute)
228+ # 20 seconds; default: 1 minute.
239229 timeout = 20.0 ,
240230)
241231
0 commit comments