Skip to main content
3 complete integration patterns from zero to production. Each workflow includes full code in 4 languages.

1. Monitor & Poll

Create an API key, start monitoring an X account, then poll for events with pagination.

Step 1: Create a Monitor

curl -X POST https://xquik.com/api/v1/monitors \
  -H "x-api-key: xq_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "elonmusk",
    "eventTypes": ["tweet.new", "tweet.reply", "tweet.quote"]
  }' | jq
Response:
{
  "id": "7",
  "username": "elonmusk",
  "xUserId": "44196397",
  "eventTypes": ["tweet.new", "tweet.reply", "tweet.quote"],
  "createdAt": "2026-02-24T10:30:00.000Z"
}

Step 2: Poll for Events

Poll on an interval and paginate through all available events.
# First page
curl "https://xquik.com/api/v1/events?monitorId=7&limit=50" \
  -H "x-api-key: xq_YOUR_KEY_HERE" | jq

# Next page (use nextCursor from previous response)
curl "https://xquik.com/api/v1/events?monitorId=7&limit=50&after=MjAyNi0wMi0yNFQxNTowNTozMC4wMDBafDkwMDI=" \
  -H "x-api-key: xq_YOUR_KEY_HERE" | jq
For real-time delivery without polling, use webhooks instead.

2. Real-Time Webhooks

Create a monitor, register a webhook endpoint, then verify signatures and process events as they arrive.

Step 1: Create a Monitor

Same as Step 1 above. You need at least 1 active monitor before events can be delivered.

Step 2: Create a Webhook

curl -X POST https://xquik.com/api/v1/webhooks \
  -H "x-api-key: xq_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook",
    "eventTypes": ["tweet.new", "tweet.reply"]
  }' | jq
The secret is returned only once. Store it securely — you need it to verify signatures on incoming deliveries.

Step 3: Handle & Verify Events

Build a webhook handler that verifies the HMAC signature before processing events.
import express from "express";
import { createHmac, timingSafeEqual } from "node:crypto";

const app = express();
const WEBHOOK_SECRET = "your_webhook_secret_here";

function verifySignature(payload, signature, secret) {
  const expected =
    "sha256=" + createHmac("sha256", secret).update(payload).digest("hex");
  return timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
}

app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const signature = req.headers["x-xquik-signature"];
  const payload = req.body.toString();

  if (!verifySignature(payload, signature, WEBHOOK_SECRET)) {
    return res.status(401).send("Invalid signature");
  }

  const event = JSON.parse(payload);

  switch (event.type) {
    case "tweet.new":
      console.log(`New tweet from @${event.username}: ${event.data.text}`);
      break;
    case "tweet.reply":
      console.log(`Reply from @${event.username}: ${event.data.text}`);
      break;
  }

  res.status(200).send("OK");
});

app.listen(3000, () => console.log("Webhook server running on :3000"));
Respond within 10 seconds. If your handler is slow, acknowledge the delivery immediately and process the event asynchronously.

3. AI Agent Integration

Connect an AI agent to Xquik via the MCP server, then use natural language to monitor accounts and retrieve events.

Step 1: Configure MCP

Add to your claude_desktop_config.json:
{
  "mcpServers": {
    "xquik": {
      "url": "https://xquik.com:3100/mcp",
      "headers": {
        "x-api-key": "xq_YOUR_KEY_HERE"
      }
    }
  }
}

Step 2: Search Tweets

Ask your AI agent:
“Search for tweets about TypeScript performance”
The agent calls the search-tweets tool:
{
  "tool": "search-tweets",
  "input": { "query": "TypeScript performance" }
}
Result:
[
  {
    "id": "1893456789012345678",
    "text": "TypeScript 6.0 compiler is 10x faster. The rewrite in Go was worth it.",
    "author": "typescript",
    "createdAt": "2026-02-24T14:22:00.000Z"
  },
  {
    "id": "1893456789012345999",
    "text": "Benchmarked our monorepo build: 45s down to 4s with the new TS compiler.",
    "author": "webdevexpert",
    "createdAt": "2026-02-24T13:10:00.000Z"
  }
]

Step 3: Monitor a User

Ask your AI agent:
“Monitor @typescript for new tweets and replies”
The agent calls the add-monitor tool:
{
  "tool": "add-monitor",
  "input": {
    "username": "typescript",
    "eventTypes": ["tweet.new", "tweet.reply"]
  }
}
Result:
{
  "id": "12",
  "username": "typescript",
  "xUserId": "809233214",
  "eventTypes": ["tweet.new", "tweet.reply"],
  "createdAt": "2026-02-24T15:00:00.000Z"
}

Step 4: Get Events

Ask your AI agent:
“Show me the latest events from my monitors”
The agent calls the get-events tool:
{
  "tool": "get-events",
  "input": { "limit": 10 }
}
Result:
{
  "events": [
    {
      "id": "9010",
      "type": "tweet.new",
      "monitorId": "12",
      "username": "typescript",
      "occurredAt": "2026-02-24T16:45:00.000Z",
      "data": {
        "tweetId": "1893556789012345678",
        "text": "TypeScript 6.0.1 patch release is out. Fixes incremental build edge cases.",
        "metrics": { "likes": 3200, "retweets": 890, "replies": 245 }
      }
    }
  ],
  "hasMore": false
}
The agent summarizes the results in natural language, giving you a clear overview without writing any code.

Example Prompts

Once connected, try these with your AI agent:
  • “Monitor @veraborovic for new tweets and quote tweets”
  • “How many followers does @elonmusk have?”
  • “Search for tweets mentioning xquik”
  • “Show me all tweet.reply events from the last page”
  • “Set up a webhook at https://my-server.com/events for new tweets”
  • “Remove the monitor for @oldaccount”
  • “List all my active webhooks”