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.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
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:- Poll an endpoint at a regular interval (1 to 30 seconds).
- Compare results against previously seen tweet IDs to identify what is new.
- Process new tweets: send alerts, store, fan out to Slack, Discord, etc.
- Repeat.
Choosing the Right Endpoint
| What you want to monitor | Endpoint | Method | Why this one |
|---|---|---|---|
| A single account | /user-tweets | POST | Returns the latest tweets from one user’s timeline |
| Up to 5,000 accounts at once | /list-tweets | GET | One request covers all members of an X List |
| A keyword or hashtag | /search-tweets | POST | Full search operator support, chronological ordering with order: latest |
| @mentions of an account | /mentions | POST | Purpose-built for mention tracking with engagement filters |
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
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
- Go to X Lists and create a list.
- Add the accounts to monitor (up to 5,000).
- Set the list to Public. Private lists are not accessible via the API.
- Copy the List ID from the URL. For
https://x.com/i/lists/1234567890the ID is1234567890.
Step 2: Poll the List
/list-tweetsreturns 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 vianext_cursoruntil 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.
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.| Interval | Req/Hour | Req/Day | Req/Month (30d) |
|---|---|---|---|
| 1 second | 3,600 | 86,400 | 2,592,000 |
| 5 seconds | 720 | 17,280 | 518,400 |
| 10 seconds | 360 | 8,640 | 259,200 |
| 30 seconds | 120 | 2,880 | 86,400 |
| 1 minute | 60 | 1,440 | 43,200 |
For volumes that exceed standard plan limits, contact [email protected] or Discord for a custom rate-limit quota.
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.
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.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-tweetsreturns an empty list. Log and continue. - Pinned tweets: the first tweet in a
/user-tweetsresponse is often the pinned one, not the most recent. Sort bycreated_atfor strict chronological order. - Retweets:
tweet["retweeted_status"]is populated for retweets. Decide whether to include them or filter out. - Reply restrictions:
is_replies_limitedindicates 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.