Skip to main content

Retrieve X/Twitter context with Haystack

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

Haystack web search components for retrieving public X/Twitter context through the Xquik REST API.

Read the Xquik Haystack guide.

This package is maintained by Xquik as a standalone Haystack integration. It follows the haystack_integrations namespace convention and exposes read-only components under:

from haystack_integrations.components.websearch.xquik import XquikTweetSearch, XquikUserTweetsFetcher

Available components

  • XquikTweetSearch: calls GET /x/tweets/search and returns matching posts as Haystack Document objects.
  • XquikUserTweetsFetcher: calls GET /x/users/{id}/tweets and returns recent public posts for a user as Haystack Document objects.

Both components:

  • read the API key from XQUIK_API_KEY by default
  • accept haystack.utils.Secret for explicit API key injection
  • send the x-api-key and xquik-api-contract: 2026-04-29 headers
  • keep base_url configurable for tests and controlled deployments
  • return documents, links, has_more, and next_cursor

Install

Install from PyPI:

pip install xquik-haystack

Search public X data

Search posts

from 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"]

Fetch user posts

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"]

Document mapping

Each tweet becomes a Haystack Document.

  • Document.content: tweet text, or an empty string when text is missing
  • Document.meta["endpoint"]: Xquik endpoint family used by the component
  • Document.meta["id"]: tweet ID when present
  • Document.meta["url"]: tweet URL when present
  • Document.meta["created_at"]: tweet creation time when present
  • Document.meta["author"]: author ID, username, display name, and verification status when present
  • Document.meta also includes available public metrics such as like, repost, reply, quote, view, and bookmark counts

Development

This project uses Hatch for build and environment management.

pip install hatch
hatch run fmt-check
hatch run test:unit
hatch build

Unit tests mock all Xquik HTTP calls. Integration tests can be added later behind an XQUIK_API_KEY check.

Publishing

The release workflow publishes to PyPI with trusted publishing when a GitHub release is published.

Haystack merged the Xquik integration-directory listing.

License

xquik-haystack is distributed under the terms of the Apache-2.0 license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xquik_haystack-0.1.3.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xquik_haystack-0.1.3-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file xquik_haystack-0.1.3.tar.gz.

File metadata

  • Download URL: xquik_haystack-0.1.3.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for xquik_haystack-0.1.3.tar.gz
Algorithm Hash digest
SHA256 32afdc753925363bf276c4086dabcf6b22a99386e3932add30604db153e8ed2d
MD5 90ad4556a81de7a2d9b1969aa1b85fbf
BLAKE2b-256 cc7a1ce83a19e6a63f4c66f9ef00b1e5bca7c35036b7f21f624af29c05c3ff6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for xquik_haystack-0.1.3.tar.gz:

Publisher: release.yml on Xquik-dev/xquik-haystack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xquik_haystack-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: xquik_haystack-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for xquik_haystack-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 804e908f95ec571e87b488071f8c45394f452767f0802c080acda268860328fd
MD5 029efa741f20834c1690d7fa69046613
BLAKE2b-256 c89ef2da7ab7008954506a9977b326cd0cec61eadcebecc36179d8a6c94bce52

See more details on using hashes here.

Provenance

The following attestation bundles were made for xquik_haystack-0.1.3-py3-none-any.whl:

Publisher: release.yml on Xquik-dev/xquik-haystack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.5

2 files

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page