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.
| 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.
pip install prefect-x-api-scraperprefect block register -m prefect_x_api_scraperfrom 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.
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}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.
TwexAPI is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.