MindCase
Kritish Puri

Automate an X Trending Topics Tracker

Run the same X search every hour, count what comes back, and flag the runs that don't look like the ones before them — the mechanism behind catching a topic before it's obviously trending.

twitterautomation
Automate an X Trending Topics Tracker

X's own "Trending" tab is already crowded by the time a topic shows up on it — reactive, and blind to anything narrower than a platform-wide trend. A brand tracking mentions of its own launch, or a research team watching a specific hashtag, needs something that notices a topic picking up before it's obvious to everyone, not a list of what's already peaked. That's a different tool than a one-off search: it's the same search, run on a schedule, with somewhere to compare this hour's count against the last one.

If you're an agent (or building one) reading this rather than a human, the full machine-readable schema for every endpoint below lives at mindcase.co/skills.md.

What does automating trend-tracking actually mean?

Three things have to happen on a schedule, not just once: the pull, the count, and the baseline.

  • The pull. The same query — a keyword, a hashtag, a handle — run the same way, on a fixed cadence. Hourly is tight enough to catch something building over a few hours; every few hours is enough for a slower-moving topic.
  • The count. Each run's result needs a single number attached to it: how many tweets matched, and how much engagement they carried. That number is what actually gets compared, not the raw tweets.
  • The baseline. A count only means something next to what came before it. Ten tweets an hour is nothing for a topic that normally runs at eight. It's a real spike for one that normally runs at one.

Most of the actual signal lives in the second and third pieces — the pull is one API call either way.

How do you pull tweet volume for a keyword on a schedule?

Say your team just shipped a new voice AI agent and wants to know within a few hours if people are talking about it on X — not find out secondhand from a support ticket a week later. Twitter/X Tweets takes a search query with real X search operators, so each hourly run is that same keyword plus whatever narrows it to tweets worth counting.

curl -X POST "https://api.mindcase.co/v1/data/twitter/tweets/run?wait=true" \
-H "Authorization: Bearer $MINDCASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "params": {
    "query": "\"voice AI agent\" -filter:replies",
    "maxResults": 100
  }
}'

# $0.00025 per tweet returned

Every row comes back with likes, retweets, replies, quotes, and views — 35 fields in total — so the count you store per run doesn't have to be just "how many tweets matched." Volume tells you a topic is being talked about; summed engagement tells you whether anyone's actually reacting to it, which is the difference between a keyword that's merely present and one that's spreading.

How do you tell an emerging spike from normal chatter?

A single run tells you nothing on its own — it's a count with no context. The comparison only works once you're storing each run's numbers somewhere that remembers the ones before it: a flat file, a spreadsheet row, a database table, whatever your automation already writes to.

An illustrative run history for one keyword makes the shape of this concrete:

HourQueryTweet CountTotal Engagement
09:00"voice AI agent"640
10:00"voice AI agent"735
11:00"voice AI agent"412,900

The count alone already says something at 11:00 — six times the prior hour. The engagement column says more: 2,900 versus 35 isn't six people repeating the same line, it's a post that's actually getting reactions. A simple rolling baseline — the average of the last several hours for that keyword — is enough to catch this without hand-tuning a model: flag any hour where the count clears some multiple of that average, say 3x, and you've caught the 11:00 row without having watched for it.

Store more than the two numbers above if the keyword matters enough to investigate later. The author field on each row identifies who's driving a spike — one account with a viral post looks different from forty separate accounts independently mentioning the same thing, and only one of those is a real trend rather than one popular tweet.

How do you turn a volume spike into something worth acting on?

Detecting the spike and doing something about it are two different steps, and only the first one is what the count-and-compare loop above gives you. Once an hour clears the threshold, pull the actual tweets from that run — you already have them from the same call — and read the handful with the highest likes or retweets first. That's usually enough to tell whether the spike is a real story worth a response, a single account's post that happened to get picked up, or noise from an unrelated use of the same words.

Where that alert goes from there — a Slack message, an email, a row in a dashboard — is your own automation's job, not something the API sends on your behalf. The API answers one request at a time; the scheduling, the storage, and the threshold check all run on whatever cron job or serverless function you're already using to call it.

What can't you get from Mindcase?

Two cases.

A built-in scheduler, storage, or alerting. The API doesn't run itself on a timer, remember last hour's count, or notify anyone when a threshold trips. All three are yours to build on top of it, the same way you'd build them on top of any other data source.

Volume from before you started tracking. Every run counts what's live on X right now. There's no historical index to backfill last week's hourly counts for a keyword you just started watching — a baseline only starts accumulating from the first run forward.

Which endpoint should you use for which job?

EndpointInputPriceBest for
Twitter/X TweetsHandle, tweet URL, or search query$0.00025 / tweetCounting volume and engagement for a keyword on a schedule

FAQ

No. Requests run against public tweet data, with real X search operators supported in the query parameter — no X login, developer account, or API tier required on your end.

Hourly is tight enough to catch a topic building over a few hours. A slower-moving keyword can run every few hours instead without missing much.

$0.00025 per tweet returned. A 100-tweet cap per hourly run costs at most $0.025 an hour, or about $0.60 a day at a full 24-hour cadence.

Each call takes one query. Tracking several keywords means looping separate calls per run, one per keyword, and storing each one's counts separately.

It can, since you're watching one keyword's own history rather than a platform-wide trending list. A topic narrow enough to never make X's Trending tab can still show a real spike against its own baseline.