Metadata-Version: 2.5
Name: prefect-x-api-scraper
Version: 0.1.0
Summary: Prefect tasks for scheduled Twitter search, profiles, timelines, and trends through TwexAPI. Not affiliated with X Corp.
Project-URL: Documentation, https://github.com/twexapi-dev/prefect-x-api-scraper
Project-URL: Homepage, https://docs.twexapi.io
Project-URL: Issues, https://github.com/twexapi-dev/prefect-x-api-scraper/issues
Project-URL: Source, https://github.com/twexapi-dev/prefect-x-api-scraper
Author: TwexAPI
License-Expression: MIT
License-File: LICENSE
Keywords: data-pipelines,prefect,prefect-collection,prefect-integration,social-media-api,tweet-search,twexapi,twitter-api,twitter-search,workflow-orchestration,x-api
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.28.1
Requires-Dist: prefect>=3.8.3
Requires-Dist: pydantic>=2.11.2
Description-Content-Type: text/markdown

# 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

```bash
pip install prefect-x-api-scraper
```

## Store credentials

```bash
prefect block register -m prefect_x_api_scraper
```

```python
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

```python
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

```python
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`:

```python
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 docs](https://docs.twexapi.io)
- [REST overview](https://docs.twexapi.io/api-reference/overview)
- [Prefect tasks](https://docs.prefect.io/v3/develop/write-tasks)

TwexAPI is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.
