xquik-haystack when a Haystack pipeline needs fresh public X context from Xquik’s REST API. The package exposes read-only web search components that return Haystack Document objects for tweet search and user timelines.
Prerequisites
- Python 3.10+
- Xquik API key (
xq_...) - Haystack application or pipeline using
haystack-ai
Install
Install the current GitHub build:Components
XquikTweetSearch
Calls
GET /x/tweets/search and returns matching public posts as Haystack
Document objects.XquikUserTweetsFetcher
Calls
GET /x/users/{id}/tweets and returns recent public posts from one
user as Haystack Document objects.Pagination Handoff
Returns
has_more and next_cursor so the next run can fetch the next
Xquik page.Pipeline Ready
Returns
documents for direct use in Haystack pipelines, retrievers,
joiners, rankers, and generators.XQUIK_API_KEY by default, accept haystack.utils.Secret for explicit key injection, support sync and async runs, and send xquik-api-contract: 2026-04-29.
Tweet Search
UseXquikTweetSearch when the pipeline needs matching tweets for a keyword, hashtag, account filter, or X search operator.
top_k maps to the Xquik limit query parameter. query_type accepts Latest for chronological results or Top for engagement-ranked results.
User Timeline
UseXquikUserTweetsFetcher when the pipeline needs recent public posts from one username or X user ID.
include_replies=True to include replies. Pass include_parent_tweet=True when reply rows should include parent tweet data when available.
Pagination
The components normalize Xquik pagination into Haystack-friendly output keys:XquikUserTweetsFetcher.run(user_id="username", cursor=...).
Runtime Options
Per-run overrides are available for
top_k, query_type, cursor, since_time, and until_time on tweet search, and for cursor, include_replies, and include_parent_tweet on user tweets.
Document Mapping
Each returned tweet becomes a HaystackDocument.
The
links output contains each non-empty tweet URL found in Document.meta["url"].
Pipeline Handoff
Use this shape when Haystack hands results to a vector store, evaluation job, queue, CSV export, or dashboard.Document Rows
Store each
Document.content, meta.endpoint, meta.id, meta.url, meta.created_at, meta.author.id, meta.author.username, meta.author.name, meta.author.verified, and public metrics before embedding or export.Citation Links
Store
links as the canonical tweet URLs returned by the component. Join them to meta.id when a citation, audit row, or UI card needs a source link.Pagination Checkpoint
Store request
query or user_id, component options, has_more, and next_cursor. Resume with cursor=next_cursor; do not decode cursors.Failure Branch
Catch
httpx.HTTPStatusError, branch on response.status_code, and store the status with the pipeline run ID instead of retrying bad inputs unchanged.document_rows, citation_rows, and pagination_checkpoints separate from embeddings so later reruns can refresh X context without rebuilding the whole pipeline.
Async Usage
Both components exposerun_async() with the same inputs and outputs as run().
Error Handling
Xquik HTTP errors are raised throughhttpx.HTTPStatusError after the response status check. Handle authentication, rate limit, payment, and validation errors where your Haystack app normally handles retriever or web search failures.