Twitter search and user timeline components for Haystack
TwexAPI is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.
Search Twitter and fetch public user timelines in Haystack RAG pipelines. Each TwexAPI result becomes a Haystack Document.
Components
| Task | Haystack component | TwexAPI route | Output |
|---|---|---|---|
| Search tweets for RAG | TwexApiTweetSearch |
POST /twitter/advanced_search/page |
Matching posts as Document objects |
| Retrieve a user's timeline | TwexApiUserTweetsFetcher |
POST /twitter/{screen_name}/timeline/page |
Recent user posts as Document objects |
from haystack_integrations.components.websearch.x_api_scraper import (
TwexApiTweetSearch,
TwexApiUserTweetsFetcher,
)
Both components read X_API_SCRAPER_KEY by default and accept a Haystack Secret. They send Authorization: Bearer. Set base_url for another TwexAPI-compatible endpoint. Results include documents, links, has_more, and next_cursor.
Search returns up to 20 tweets per page. Timeline top_k maps to the page count (1-100). Use REST or an SDK for follower pagination or approved posting.
Install
pip install x-api-scraper-haystack
Build a Haystack RAG pipeline with Twitter search
Search posts
from haystack import Pipeline
from haystack.utils import Secret
from haystack_integrations.components.websearch.x_api_scraper import TwexApiTweetSearch
search = TwexApiTweetSearch(api_key=Secret.from_env_var("X_API_SCRAPER_KEY"), top_k=10)
pipeline = Pipeline()
pipeline.add_component("x_search", search)
result = pipeline.run({"x_search": {"query": "haystack ai"}})
documents = result["x_search"]["documents"]
Fetch user posts
from haystack.utils import Secret
from haystack_integrations.components.websearch.x_api_scraper import (
TwexApiUserTweetsFetcher,
)
fetcher = TwexApiUserTweetsFetcher(api_key=Secret.from_env_var("X_API_SCRAPER_KEY"))
result = fetcher.run(screen_name="elonmusk")
documents = result["documents"]
Document mapping
Each tweet becomes a Haystack Document with this mapping.
Document.content:full_textortext, or an empty string when both are missingDocument.meta["endpoint"]:searchortimelineDocument.meta: availableid,url, andcreated_atsource valuesDocument.meta["author"]: available author identity and verification dataDocument.meta: available like, retweet, reply, quote, view, and bookmark counts
License
MIT. TwexAPI is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.
Metadata
Release files for x-api-scraper-haystack 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 | |
|---|---|---|---|---|
| x_api_scraper_haystack-0.1.0.tar.gz | 132.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| x_api_scraper_haystack-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 143.1 kB
Release files / x_api_scraper_haystack-0.1.0.tar.gz
| Download URL | x_api_scraper_haystack-0.1.0.tar.gz |
|---|---|
| Size | 132.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a4d78e45645af7f42ff70d7a1218f630646e5bddae94458a264684130a9124f
|
|
BLAKE2b-256 checksum How to use checksums |
d4a25328685254475c4b00c706911a8f82e677fa6cff37e26da1df6ba67cc89d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / x_api_scraper_haystack-0.1.0-py3-none-any.whl
| Download URL | x_api_scraper_haystack-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f537a2cebccc27b016939ddcc3bb2600cbc8f3e0f7d512fc2610f92524e06c2
|
|
BLAKE2b-256 checksum How to use checksums |
5ea7243c851214430106521ae9d822cb1bff3ad1968adc8e2eaef7785b6dff16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for x-api-scraper-haystack 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.