A normal Apify run takes three steps: start the Actor, wait for it to finish, fetch the dataset. That’s fine for a nightly job. It’s awkward when a Slack command or a dashboard button is waiting for the answer. X.com Twitter API Scraper now has a server mode (Apify Standby) for that case: you send one request and the tweets come back in the response.

This post covers the endpoint, the parts of the response a client has to check, what it costs, and a Node.js client I tested against a mock server.

The endpoint

The server lives at https://xtdata--twitter-x-scraper.apify.actor. Authenticate with your Apify token as Authorization: Bearer <APIFY_TOKEN>. There is one data route, /tweets, and it accepts GET and POST.

With GET, put the query in the URL. Several parameters can be repeated or comma-separated:

Parameter Meaning
searchTerm (or q) A search query. Advanced operators work, e.g. from:NASA AI
handle A handle without @
url A profile, search, list or tweet URL
tweetId, conversationId Replies of a conversation (add scrapeReplies=true for tweet IDs)
maxItems Tweets per query, 1 to 200, default 20
cursor Pagination cursor from a previous response
sort Top, Latest or Both
tweetLanguage, start, end Language code and YYYY-MM-DD date range

POST /tweets takes a JSON body with the same fields as the Actor’s input form (searchTerms, twitterHandles, startUrls, tweetIds, conversationIds, maxItems, sort and so on). It also accepts customMapFunction, which GET doesn’t.

Limits per request: 200 tweets per query, 5 queries, and a 5-minute ceiling. onlyNewTweets isn’t available here; see the last section.

curl -G -H "Authorization: Bearer $APIFY_TOKEN" \
  "https://xtdata--twitter-x-scraper.apify.actor/tweets" \
  --data-urlencode "searchTerm=from:NASA" \
  --data-urlencode "maxItems=20" \
  --data-urlencode "sort=Latest"

A 200 doesn’t always mean complete

The response is an object with items and meta:

{
  "items": [ { "id": "…", "full_text": "…", "favorite_count": 14, "viewCount": 1520, "author": { "screen_name": "NASA" } } ],
  "meta": {
    "queries": 1, "failed": 0, "returned": 20, "maxItemsPerQuery": 20,
    "nextCursor": "…", "hasMore": true,
    "partial": false, "timedOut": false, "chargeLimitReached": false
  }
}

Three of these flags change what a client should do:

  • hasMore and nextCursor: pass nextCursor back as cursor to get the next page. Paging works for a single query only; with several queries (or sort=Both) the server returns a 400 if you send a cursor.
  • chargeLimitReached: the Actor stopped because your maximum cost was hit. This arrives as a normal 200, not a 402, so a client that only checks the status code will carry on and treat a short page as a complete one.
  • partial: true when a request timed out, hit the budget, or at least one query failed. With several queries, the others are still returned and failed tells you how many didn’t make it.

Errors that aren’t partial results use the status code: 400 with { "error": "…" } for bad input (too many queries, an empty query, a cursor with several queries), and 500 with { "error": "Failed to retrieve tweets." } when the scrape itself failed.

A Node.js client

This is Node 18+ with the built-in fetch. It retries only on 429 and 5xx responses (and network errors), because a 400 won’t succeed on a second try. It pages with the cursor until it has limit tweets, and it returns a stoppedBy reason, so the caller knows whether it got everything.

// xtweets.mjs
const BASE = 'https://xtdata--twitter-x-scraper.apify.actor';
const TOKEN = process.env.APIFY_TOKEN;

export class BadRequestError extends Error {}

const RETRYABLE = new Set([429, 500, 502, 503, 504]);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function postTweets(body, { retries = 3 } = {}) {
  for (let attempt = 0; ; attempt++) {
    let res;
    try {
      res = await fetch(`${BASE}/tweets`, {
        method: 'POST',
        headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(300_000),
      });
    } catch (err) {
      if (attempt >= retries) throw err; // network error or timeout
    }
    if (res?.ok) return res.json();

    if (res && !RETRYABLE.has(res.status)) {
      const payload = await res.json().catch(() => ({}));
      const message = payload.error?.message ?? payload.error ?? `HTTP ${res.status}`;
      throw new BadRequestError(message);
    }
    if (attempt >= retries) throw new Error(`Gave up after ${attempt + 1} attempts`);
    await sleep(1000 * 2 ** attempt + Math.random() * 500);
  }
}

export async function searchTweets(searchTerm, { limit = 100, pageSize = 50, ...filters } = {}) {
  const items = [];
  let cursor;

  while (items.length < limit) {
    const { items: page, meta } = await postTweets({
      searchTerms: [searchTerm],
      maxItems: Math.min(pageSize, limit - items.length),
      sort: 'Latest',
      ...filters,
      ...(cursor && { cursor }),
    });
    items.push(...page);

    if (meta.chargeLimitReached) return { items, stoppedBy: 'budget' };
    if (!meta.hasMore) return { items, stoppedBy: meta.failed ? 'failed' : 'end' };
    cursor = meta.nextCursor;
  }
  return { items, stoppedBy: 'limit' };
}

Using it:

import { searchTweets } from './xtweets.mjs';

const { items, stoppedBy } = await searchTweets('from:NASA', { limit: 120, tweetLanguage: 'en' });
console.log(items.length, stoppedBy); // e.g. 120 'limit'

I ran this client against the live server: a 12-tweet search in pages of 5, and an empty query, which returned the 400 above. The retry and budget branches are hard to trigger on demand, so I tested those against a local mock server that returns the same response shapes.

The loop sends pageSize as maxItems, so with limit: 120 and pageSize: 50 it asks for 50, 50 and then 20. stoppedBy: 'budget' is the case I’d alert on: the tweets you already have are valid, and the rest are missing because the cost cap stopped the Actor.

stoppedBy: 'end' means the server found no more tweets at that moment, which is not quite a guarantee. In one of my live runs, a 12-tweet search with pages of 5 stopped at 10 tweets with hasMore: false. Repeating the call returned all 12. If you need a list to be complete, retry once before you accept a short result.

What it costs

Server mode uses the same pay-per-event pricing as a normal run. Per the Pricing tab on the Actor page (checked 29 Nov 2026), you pay a start event once per server run, and a result-item event for each tweet returned. Tweets are charged directly, without writing to a dataset, and idle time between requests isn’t charged.

The per-tweet price depends on your Apify plan:

Plan Per tweet
Free $0.005
Bronze $0.0008
Silver $0.0006
Gold and above $0.00025

A full 200-tweet query therefore costs about $1.00 on the Free plan and about $0.05 on Gold. Pick maxItems with that in mind, because every returned tweet is billed.

When to use a batch run instead

Server mode is for “someone is waiting”. Switch back to the normal input form for:

  • Monitoring. onlyNewTweets remembers what you’ve already received and only works in scheduled runs. For a single account’s timeline, Twitter (X) User Tweets Scraper is built for that job.
  • Big exports. A batch run gives you one dataset with a record of what was collected, and you aren’t limited to 5 queries per call.

Using it from an AI agent

The README documents an MCP connection for Claude Desktop, Cursor or any MCP client. The tool URL is https://mcp.apify.com/?tools=xtdata/twitter-x-scraper, with your token in an Authorization header. An agent that needs “recent posts about X” can call the Actor directly, without a client of your own.

If you build something with /tweets, I’d like to hear which of the meta flags your client ended up relying on. Mine was chargeLimitReached.