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.1.tar.gz (16.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.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xquik_haystack-0.1.1.tar.gz
  • Upload date:
  • Size: 16.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.1.tar.gz
Algorithm Hash digest
SHA256 90e8c289d929b07bd069487ab3f4137e85f01f8b569c22247f4e5b727e981418
MD5 c73c06abc364321fe782c1a6c9e39ff4
BLAKE2b-256 ad8dc4671e4a222062ab56e961123e29bea2d915053ca6e1c6ec20075001bf1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for xquik_haystack-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: xquik_haystack-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b375944d17ea7e9d83f1359f492098d6b1596fdff5c812562b835c67e70b69ea
MD5 ca3e3b7149fc6c62906924c35a2ce4b9
BLAKE2b-256 ecc989a2f49577137e39ddd632b5a819defa4b27140cd4d6c11943a13f317b25

See more details on using hashes here.

Provenance

The following attestation bundles were made for xquik_haystack-0.1.1-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

0.1.3

2 files

This release

0.1.1 This release

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