Skip to main content

Real-Time Monitoring

Detect new tweets from specific accounts, track keyword mentions as they happen, and feed live X data into your application. This guide shows how to build a near-real-time monitoring pipeline on top of the Sorsa API using a pull-based polling pattern. Sorsa returns fresh data on every request. If a tweet was posted half a second ago, the next API call will include it. Combined with a 20 requests-per-second rate limit and response times around 300ms, polling-based loops match or beat most managed streaming services for the use cases below, without persistent connections, reconnect logic, or OAuth.
Free to prototype: Every Sorsa endpoint is available on your first 100 requests: one-time, no credit card, no expiry. That is enough to stand up any of the monitors below, confirm it detects live tweets, and validate your Slack or Discord routing before choosing a plan. Because polling is request-heavy, size a paid plan to your poll interval using the usage table further down.
Note: For a fuller walkthrough with additional architecture patterns and end-to-end examples, see Real-Time Twitter Monitoring with REST API on the blog.

How Polling-Based Monitoring Works

There are two ways to get data from a social platform: push-based (streaming, webhooks) or pull-based (polling). The Sorsa API uses polling. The pattern has four steps:
  1. Poll an endpoint at a regular interval (1 to 30 seconds).
  2. Compare results against previously seen tweet IDs to identify what is new.
  3. Process new tweets: send alerts, store, fan out to Slack, Discord, etc.
  4. Repeat.
Tweet IDs (Snowflake) are monotonically increasing, so deduplication is reliable: a higher ID always means a newer tweet. If a script crashes, it resumes from the last checkpoint on the next poll. No persistent connection to manage, no reconnect strategy required.

Choosing the Right Endpoint


Level 1: Monitor a Single Account

The simplest case. The loop polls /user-tweets and emits tweets newer than the last seen ID.

Python

JavaScript

This scales poorly for many accounts. Monitoring 50 accounts means 50 separate loops and 50x the API requests. That is where X Lists come in.

Level 2: Monitor Many Accounts with a Single Request

X Lists group up to 5,000 accounts. /list-tweets returns the merged latest tweets across all members in one API call. This is the default pattern for production multi-account monitoring. See Lists & Communities for more.

Step 1: Create a Public X List

  1. Go to X Lists and create a list.
  2. Add the accounts to monitor (up to 5,000).
  3. Set the list to Public. Private lists are not accessible via the API.
  4. Copy the List ID from the URL. For https://x.com/i/lists/1234567890 the ID is 1234567890.

Step 2: Poll the List

Efficiency gain. Polling 50 accounts individually at a 10-second interval costs 50 x 8,640 = 432,000 requests per day. The same 50 accounts in one List polled at 10 seconds costs 8,640 requests per day. A 50x reduction. For more patterns like this, see Optimizing API Usage.
/list-tweets returns up to 20 tweets per page. If list members tweet faster than that within one poll interval, drop the interval to 2 to 3 seconds, or paginate via next_cursor until reaching a previously seen ID.

Level 3: Monitor a Keyword or Hashtag

Instead of tracking accounts, poll /search-tweets with order: "latest" for chronological results matching a query.
Any search operator works in the query string. To monitor high-engagement English mentions of your brand and exclude retweets:

Routing New Tweets to Slack, Discord, or Any HTTP Endpoint

The polling loop is the producer; the callback decides what happens to each new tweet. Because the callback is just a function, the same monitor can route to anything that speaks HTTP.

Slack via Incoming Webhook

Discord

Telegram

Any Custom HTTP Endpoint


API Usage Calculator

Polling uses one request per cycle. Pick an interval that balances latency against monthly request volume. For most social listening and brand monitoring, 10 to 30 seconds is sufficient: any new tweet is detected within half a minute. Reserve 1 to 5 second intervals for financial signal detection or breaking-news pipelines. The free 100 requests are enough to prototype and validate a monitor end to end. For sustained monitoring, match a plan to the monthly volume in the table above: a single loop at 30 to 60 seconds fits within Pro (100,000 requests per month), and a single loop at 10 seconds fits within Enterprise (500,000 requests per month). These figures are per monitor, so running several in parallel multiplies the total; size your plan to the combined volume. See Pricing for full plan details.
For rate limits or volumes above the standard plans, talk to sales for a custom quota, or ask in Discord.

Production Hardening

The examples above work for development. For production, address these five concerns.

1. Persist last_seen_id Across Restarts

If the script crashes and restarts without remembering its checkpoint, it either reprocesses old tweets (duplicate alerts) or silently skips the gap. Store the last seen ID in a file, database, or Redis.
Load on startup, save after every successful poll that updates the cursor.

2. Exponential Backoff for Errors

Network issues, rate limits (HTTP 429), and transient API errors will happen. Back off gradually with a cap rather than retrying immediately. See Error Codes for the full reference.

3. Separate Polling from Processing

Do not run expensive operations (NLP, database writes, external API calls) synchronously inside the polling loop. If a downstream system slows down, the loop falls behind schedule. Push new tweets into a queue and process them in a separate worker.
For heavier workloads, replace the in-memory deque with Redis, RabbitMQ, SQS, or any message broker the stack already uses.

4. Monitor the Monitor

Log each poll cycle: timestamp, new tweet count, response time, errors. Alert if the monitor has not completed a successful poll in the last N minutes; silent failures cause invisible data gaps in alerting pipelines. Operational status of the API is available at the Sorsa Status Page.

5. Handle Edge Cases

  • Deleted tweets: if a tweet is deleted between fetch and callback, the URL will 404. Treat as expected.
  • Protected accounts: if a tracked user goes private, /user-tweets returns an empty list. Log and continue.
  • Pinned tweets: the first tweet in a /user-tweets response is often the pinned one, not the most recent. Do not use tweets[0] as the newest ID; take max(int(t["id"]) for t in tweets) instead (as the examples above do), or sort by created_at.
  • Retweets: tweet["retweeted_status"] is populated for retweets. Decide whether to include them or filter out.
  • Reply restrictions: is_replies_limited indicates the author restricted replies; useful signal for some monitoring use cases.

Next Steps

  • Search Operators: advanced filters to reduce noise in keyword-based monitoring.
  • Track Mentions: dedicated endpoint for @mentions with engagement filters.
  • Rate Limits: handling 429 errors and request patterns.
  • Pagination: backfill historical data alongside real-time monitoring.
  • API Reference: full specification for /list-tweets, /user-tweets, /search-tweets, and all Sorsa API endpoints.