Retrieve public X/Twitter context through Xquik.
Choose these components when Haystack pipelines need tweet Document objects.
Read the Xquik Haystack guide.
| Retrieval question | Haystack component | Xquik route | Output |
|---|---|---|---|
| How do I search tweets for RAG? | XquikTweetSearch |
GET /x/tweets/search |
Matching posts as Document objects |
| How do I retrieve a user's timeline? | XquikUserTweetsFetcher |
GET /x/users/{id}/tweets |
Recent user posts as Document objects |
This package exposes 2 read-only components. Use an Xquik SDK for follower exports or posting.
Import both read-only components from the Haystack integration namespace:
from haystack_integrations.components.websearch.xquik import XquikTweetSearch, XquikUserTweetsFetcherBoth components:
- Read
XQUIK_API_KEYby default. - Accept
haystack.utils.Secretfor explicit keys. - Send
x-api-keyandxquik-api-contract: 2026-04-29. - Allow a custom
base_urlfor controlled deployments. - Return
documents,links,has_more, andnext_cursor.
Install from PyPI:
pip install xquik-haystackfrom haystack import Pipeline
from haystack.utils import Secret
from haystack_integrations.components.websearch.xquik import XquikTweetSearch
search = XquikTweetSearch(api_key=Secret.from_env_var("XQUIK_API_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"]from haystack.utils import Secret
from haystack_integrations.components.websearch.xquik import XquikUserTweetsFetcher
fetcher = XquikUserTweetsFetcher(api_key=Secret.from_env_var("XQUIK_API_KEY"))
result = fetcher.run(user_id="example_user", include_replies=False)
documents = result["documents"]Each tweet becomes a Haystack Document.
Document.content: tweet text, or an empty string when text is missingDocument.meta["endpoint"]: Xquik endpoint family used by the componentDocument.meta["id"]: tweet ID when presentDocument.meta["url"]: tweet URL when presentDocument.meta["created_at"]: tweet creation time when presentDocument.meta["author"]: author ID, username, display name, and verification status when presentDocument.metaalso includes available public metrics such as like, repost, reply, quote, view, and bookmark counts
This project uses Hatch for build and environment management.
pip install hatch
hatch run fmt-check
hatch run test:unit
hatch buildUnit tests mock all Xquik HTTP calls.
xquik-haystack is distributed under the terms of the Apache-2.0 license.
Xquik is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.