Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xquik.com/llms.txt

Use this file to discover all available pages before exploring further.

Use the prefect-xquik collection when a Prefect flow needs scheduled X (Twitter) reads: tweet search, tweet lookup, user search, user lookup, user timelines, or regional trends. The current 0.1.4 release is read-focused. It ships one credentials block, an async Xquik client, and 6 Prefect tasks that return raw Xquik JSON dictionaries for downstream tasks, warehouses, dashboards, or alerts.

Prerequisites

  • Xquik API key
  • Python 3.10+
  • Prefect 3
  • Prefect work pool or local runner for scheduled deployments

Scheduled Workflows

Social Listening

Schedule search_tweets to collect recent or top posts for a saved query, then pass raw JSON to reporting tasks.

Profile Enrichment

Use search_users and get_user to enrich customer, creator, or competitor records with current public profiles.

Timeline Refresh

Run get_user_tweets on a schedule to refresh public timelines with optional replies and parent-tweet context.

Trend Alerts

Call get_trends for worldwide or regional topics before downstream alert, dashboard, or warehouse steps.

Install

PyPI publication is pending. Install the pinned GitHub release wheel:
pip install \
  https://github.com/Xquik-dev/prefect-xquik/releases/download/v0.1.4/prefect_xquik-0.1.4-py3-none-any.whl
Register the block type with Prefect:
prefect block register -m prefect_xquik

Credential Block

Store the API key in a Prefect block, not in flow source files. Set base_url to the public Xquik REST base URL when creating the block.
from prefect_xquik import XquikCredentials

credentials = XquikCredentials(
    api_key="xq_YOUR_KEY_HERE",
    base_url="https://xquik.com/api/v1",
)
credentials.save("xquik", overwrite=True)
If you create the block in the Prefect UI, use these values:

Block Type

Xquik Credentials

API Key

Paste an Xquik API key from the dashboard.

Base URL

https://xquik.com/api/v1

API Contract

Keep 2026-04-29 unless you intentionally pin a different public contract.

Collection Shape

Credentials

XquikCredentials stores the API key, base URL, contract header, and timeout.

Client

XquikClient uses httpx.AsyncClient, sends x-api-key, and raises XquikError for request or response failures.

Tasks

6 async Prefect tasks cover read workflows for tweets, users, user timelines, and trends.

Returns

Tasks return raw Xquik JSON dictionaries. Shape rows in later Prefect tasks.

Retries

Use Prefect task options for retry policy and delay.

Scope

Version 0.1.4 is read-only. Use REST, SDKs, or MCP for writes, monitors, webhooks, and extraction jobs.

Tasks

Search Tweets

search_tweets(credentials, query, limit=25, query_type="Latest") calls GET /x/tweets/search.

Get Tweet

get_tweet(credentials, tweet_id) calls GET /x/tweets/{id}.

Search Users

search_users(credentials, query, cursor=None) calls GET /x/users/search.

Get User

get_user(credentials, user_id) calls GET /x/users/{id}. Usernames may include @.

Get User Tweets

get_user_tweets(credentials, user_id, include_replies=False) calls GET /x/users/{id}/tweets.

Get Trends

get_trends(credentials, woeid=1, count=30) calls GET /x/trends.

Copy-Ready Flow

Use this flow when a scheduled job should capture current posts and worldwide trends for a reporting task.
from __future__ import annotations

from prefect import flow
from prefect_xquik import XquikCredentials, get_trends, search_tweets


@flow
async def social_signal_flow() -> dict[str, object]:
    credentials = XquikCredentials.load("xquik")

    tweets = await search_tweets(
        credentials,
        query='"prefect" OR "workflow orchestration"',
        query_type="Latest",
        limit=25,
    )
    trends = await get_trends(credentials, woeid=1, count=10)

    return {"tweets": tweets, "trends": trends}


if __name__ == "__main__":
    import asyncio

    asyncio.run(social_signal_flow())
Run it locally:
python social_signal_flow.py
Create a Prefect deployment when the flow is ready for a schedule:
prefect deploy social_signal_flow.py:social_signal_flow --name xquik-social-signals

Result Handoff

Tweet Pages

search_tweets and get_user_tweets return tweets, has_next_page, and next_cursor. Store the cursor with the job checkpoint.

User Pages

search_users returns users, has_next_page, and next_cursor. get_user returns one public profile dictionary.

Trend Pages

get_trends returns trends, count, and woeid. Trend rows include name and can include description, query, and rank.

Downstream Rows

Normalize raw dictionaries in a follow-up task before writing to Slack, Sheets, a warehouse, or a dashboard.

Retry Pattern

Wrap the task with Prefect options when you want retries around transient API, network, or rate-limit failures.
from prefect_xquik import search_tweets

search_recent_tweets = search_tweets.with_options(
    name="Search Recent X Posts",
    retries=2,
    retry_delay_seconds=10,
)
Then call the configured task inside a flow:
page = await search_recent_tweets(
    credentials,
    query="workflow orchestration lang:en",
    query_type="Latest",
    limit=100,
)
Respect Retry-After for repeated 429 responses, and keep limit at or below 200 for tweet search pages.

Failure Routing

XquikError exposes status_code and response_text when an HTTP response is available. Use them to decide whether the flow should fail fast, pause for account action, or retry later.

Inspect Status

Catch XquikError and branch on status_code. Store response_text with the failed run for debugging.

Fix Inputs

Treat 400 and 404 as non-retryable. Fix the query, ID, username, or cursor before rerunning.

Pause Billing Stops

Treat 402 as an account action. Check subscription or credits before the next schedule.

Back Off Reads

Treat 429, 500, 502, and 503 as retryable with Prefect retry settings and slower schedules.

Pagination Handoff

Xquik returns cursor fields for paginated reads. Store the cursor in your task result or downstream state, then pass it back unchanged on the next run.
first_page = await search_tweets(
    credentials,
    query="prefect lang:en",
    limit=100,
)

next_cursor = first_page.get("next_cursor") or first_page.get("nextCursor")

if next_cursor:
    second_page = await search_tweets(
        credentials,
        query="prefect lang:en",
        cursor=str(next_cursor),
        limit=100,
    )
Do not decode cursors. Treat them as opaque strings.

Production Notes

Credentials

Store API keys in Prefect blocks. Do not put API keys in deployment YAML, repository files, or logs.

Billing

X data reads use credits. Handle 402 no_subscription, 402 no_credits, and 402 insufficient_credits before retrying.

Rate Limits

Read endpoints share a 10 per 1s user bucket. Retry only after the Retry-After window.

Raw JSON

Shape records in follow-up tasks before writing to Slack, Sheets, a warehouse, or a dashboard.

Read Scope

Use this collection for reads. Use REST, SDKs, or MCP when a flow needs writes, monitors, webhooks, or extraction jobs.

Version Pin

Pin the release wheel in production images until PyPI publication is available.

Next Steps

  • Read Rate Limits for retry and backoff guidance.
  • Read Error Handling for 401, 402, 429, and 5xx recovery.
  • Use Extraction Workflow when a job needs durable CSV, JSON, XLSX, Markdown, or PDF exports.
  • Use MCP Tools when an AI agent should decide which Xquik endpoint to call.
Last modified on May 13, 2026