Prefect tasks for Twitter search and X API workflows
TwexAPI is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.
Schedule 6 read-only Twitter search, profile, timeline, and trend tasks in Prefect 3. Store API keys in Prefect blocks.
Tasks
| Workflow step | Prefect task | TwexAPI route |
|---|---|---|
| Search tweets | search_tweets |
POST /twitter/advanced_search/page |
| Read tweet detail | get_tweet |
POST /v2/tweet/detail |
| Search users | search_users |
GET /twitter/search-user/{keyword}/{target_count} |
| Read a profile | get_user |
GET /twitter/{screen_name}/about |
| Read a timeline page | get_user_tweets |
POST /twitter/{screen_name}/timeline/page |
| Read trending tweets | get_trends |
GET /twitter/global-trending/tweets |
Use REST or an SDK for follower pagination or approved posting.
Install
pip install prefect-x-api-scraper
Store credentials
prefect block register -m prefect_x_api_scraper
from prefect_x_api_scraper import TwexApiCredentials
credentials = TwexApiCredentials(api_key="your_twexapi_key")
credentials.save("twexapi", overwrite=True)
Keep API keys in Prefect blocks. Never put them in flow source files.
Create a flow
from prefect import flow
from prefect_x_api_scraper import TwexApiCredentials, get_trends, search_tweets
@flow
async def twitter_signal_flow() -> dict:
credentials = TwexApiCredentials.load("twexapi")
tweets = await search_tweets(
credentials,
'"prefect" OR "workflow orchestration"',
sort_by="Latest",
)
trends = await get_trends(credentials, country="United States", count=10)
return {"tweets": tweets, "trends": trends}
Import tasks
from prefect_x_api_scraper import (
get_trends,
get_tweet,
get_user,
get_user_tweets,
search_tweets,
search_users,
)
Tasks return the raw TwexAPI JSON payload and support Prefect with_options:
from prefect_x_api_scraper import search_tweets
search_recent_tweets = search_tweets.with_options(
name="Search recent tweets",
retries=2,
retry_delay_seconds=10,
)
The credentials block sends Authorization: Bearer.
Documentation
TwexAPI is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefect_x_api_scraper-0.1.0.tar.gz.
File metadata
- Download URL: prefect_x_api_scraper-0.1.0.tar.gz
- Upload date:
- Size: 200.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7108e4974d5721abedcd13fa8fb9f0ae1e82b0497414eb6cdb46a26bb7a3d95
|
|
| MD5 |
c78f9629a65ca11a6944065c55c9a834
|
|
| BLAKE2b-256 |
f67249d0e0935d1c1fe6157d106e69fe2c296db0c38726decf1eb660fb2f9dae
|
File details
Details for the file prefect_x_api_scraper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prefect_x_api_scraper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edc956b2818c7c8db6a483579c07875efd224140f5758e5a1baf3f10a4a802f5
|
|
| MD5 |
c5f6211fb49567ad0fa543d4666bbecb
|
|
| BLAKE2b-256 |
bc32233d4972767b4aefff7ccf840cbcc014290438f2b673927ceb09ab4e69bb
|