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.
Metadata
Release files for prefect-x-api-scraper 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| prefect_x_api_scraper-0.1.0.tar.gz | 200.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prefect_x_api_scraper-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 208.1 kB
Release files / prefect_x_api_scraper-0.1.0.tar.gz
| Download URL | prefect_x_api_scraper-0.1.0.tar.gz |
|---|---|
| Size | 200.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7108e4974d5721abedcd13fa8fb9f0ae1e82b0497414eb6cdb46a26bb7a3d95
|
|
BLAKE2b-256 checksum How to use checksums |
f67249d0e0935d1c1fe6157d106e69fe2c296db0c38726decf1eb660fb2f9dae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / prefect_x_api_scraper-0.1.0-py3-none-any.whl
| Download URL | prefect_x_api_scraper-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edc956b2818c7c8db6a483579c07875efd224140f5758e5a1baf3f10a4a802f5
|
|
BLAKE2b-256 checksum How to use checksums |
bc32233d4972767b4aefff7ccf840cbcc014290438f2b673927ceb09ab4e69bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for prefect-x-api-scraper 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.