# How to Monitor a Keyword on X With an API

To monitor a keyword on X, run a search query on a schedule, for example every hour, keep the IDs of posts you've already seen, and alert on the new ones.

[![apidojo](/blog/authors/apidojo.png)**Apidojo** *15+ years of experience in data retrieval.*](/blog/authors/apidojo/)

**7 October 2026** Published

**4 min** Read

![Cover card reading 'How to Monitor a Keyword on X With an API'](/blog/covers/monitor-keyword.png)

**To monitor a keyword on X, run a search query on a schedule, for example every hour, keep the IDs of posts you’ve already seen, and alert on the new ones.** apidojo’s [Twitter Scraper Unlimited](https://apify.com/apidojo/twitter-scraper-lite) suits this because it allows repeated small queries: each hourly query costs $0.016 and includes about 40 posts.

This guide builds a keyword monitor: the query, the schedule, deduplication, alerts and costs. It turns the one-time searches in [how to find viral tweets about any topic](/blog/twitter-search/find-viral-tweets/) into a recurring feed.

## Which apidojo Actor Should You Use for Monitoring?

**Use Twitter Scraper Unlimited for monitoring, not Tweet Scraper V2.** Tweet Scraper V2’s rules forbid running the same query repeatedly at short intervals and require at least 50 tweets per query, while Twitter Scraper Unlimited has no minimum and charges per query ([Tweet Scraper V2](https://apify.com/apidojo/tweet-scraper), Twitter Scraper Unlimited).

| Point | Twitter Scraper Unlimited | Tweet Scraper V2 |
| --- | --- | --- |
| Repeated queries | Allowed | Not allowed |
| Minimum per query | None | 50 tweets |
| Price | $0.016 per query (about 40 posts included), then from $0.0004 per item | $0.40 per 1,000 tweets |
| Concurrency | One run at a time | One run at a time |

## How Do You Write a Monitoring Query?

**Write a monitoring query that catches every way people mention the keyword, removes your own posts and reposts, and covers a window slightly longer than your schedule.** The `within_time:` operator limits results to the last hours ([twitter-advanced-search reference](https://github.com/igorbrigadir/twitter-advanced-search)).

```
("acme" OR @acme OR acme.com) -from:acme -filter:retweets within_time:2h
```

A 2-hour window on an hourly schedule overlaps each run with the last, so no post falls between runs; deduplication removes the repeats. Operators for variants and exclusions are in [how to search multiple keywords on X with OR](/blog/twitter-search/search-multiple-keywords-or/) and [how to exclude words from Twitter search](/blog/twitter-search/exclude-words/).

## How Do You Build the Monitor in Python?

**Run the query, compare post IDs with a stored set, and send only new posts to your alert channel.** The fields come from the actor’s output example (Apify).

```
import json, os, pathlib, requests
from apify_client import ApifyClient

QUERY = '("acme" OR @acme) -from:acme -filter:retweets within_time:2h'
SEEN = pathlib.Path("seen_ids.json")
client = ApifyClient(os.environ["APIFY_TOKEN"])

seen = set(json.loads(SEEN.read_text())) if SEEN.exists() else set()
run = client.actor("apidojo/twitter-scraper-lite").call(run_input={
    "searchTerms": [QUERY],
    "sort": "Latest",
})

new = [t for t in client.dataset(run.default_dataset_id).iterate_items() if t["id"] not in seen]
for t in new:
    requests.post(os.environ["SLACK_WEBHOOK_URL"], json={"text": f"{t['author']['userName']}: {t['text']}\n{t['url']}"})
    seen.add(t["id"])

SEEN.write_text(json.dumps(sorted(seen)))
print(len(new), "new posts")
```

The alert here goes to a Slack incoming webhook; swap in email or any HTTP endpoint. The Python setup is in [how to collect tweets with Python](/blog/twitter-scraping/scrape-tweets-python/).

## How Do You Run the Monitor on a Schedule?

**Run the script with cron on your own server, or schedule the actor run in Apify and process its dataset afterwards.** An hourly cron entry looks like this:

```
0 * * * * /usr/bin/python3 /opt/monitor/monitor.py
```

Twitter Scraper Unlimited allows one concurrent run, so keep the interval longer than a run takes (Apify).

## What Does Keyword Monitoring Cost?

**An hourly monitor costs about $0.38 a day in query fees, or about $11.52 over 30 days, plus $0.0004 for each post beyond the first 40 in a run.** A quieter keyword stays inside the included posts; a busy one adds item costs (Apify).

| Schedule | Queries per 30 days | Query fees |
| --- | --- | --- |
| Every 6 hours | 120 | $1.92 |
| Every hour | 720 | $11.52 |
| Every 15 minutes | 2,880 | $46.08 |

Polling the X API’s recent search instead costs $0.005 for every post returned, with a 3 million post reads monthly cap on pay-per-use ([X API pricing](https://docs.x.com/x-api/getting-started/pricing)).

## What Can You Build on a Keyword Monitor?

**A keyword monitor is the base for 4 common tools.** Listed below are the guides for each.

-   [How to build a Twitter mention monitor](/blog/twitter-scraping/mention-monitor/) for brand and handle mentions.
-   [How to build a competitor tweet tracker](/blog/twitter-scraping/competitor-tweet-tracker/) for rival accounts.
-   [How to collect tweets for sentiment analysis](/blog/twitter-scraping/sentiment-analysis-dataset/) for scoring opinion over time.
-   [How to build a Twitter dataset for LLM and RAG projects](/blog/twitter-scraping/llm-rag-dataset/) for AI pipelines.

## The scrapers behind this

-   [Twitter Scraper Unlimited Single tweets, reply threads, X Articles and small queries; no minimum $0.016 / query + $0.40 / 1K](/scrapers/twitter-scraper-lite/)
-   [Tweet Scraper V2 Tweets from searches, profiles, Lists and URLs; 49–64 tweets/sec; minimum 50 per query $0.40 / 1K tweets](/scrapers/twitter-scraper/)

## Questions people ask

### Can you monitor X in real time?

Scheduled searches give near real-time results at the interval you choose; true streaming requires the X API's paid event delivery.

### How do you avoid duplicate alerts?

Store the IDs of posts already sent and skip them, as in the script above.

### Can you monitor several keywords?

Yes, list several queries in `searchTerms`; batches of up to 5 queries get the lowest per-item price.

### Where do you start?

At the [apidojo Twitter Scraper](/scrapers/twitter-scraper/).

## More X data use cases

-   [How to Build a Twitter Mention Monitor Build a mention monitor for X that catches tagged and untagged mentions, sorts them into complaints, questions and praise, and alerts your team.](/blog/twitter-scraping/mention-monitor/)
-   [How to Build a Competitor Tweet Tracker Track competitors' posts, engagement, formats and follower growth on X with a daily collector and a weekly pandas report.](/blog/twitter-scraping/competitor-tweet-tracker/)
-   [How to Collect Tweets for Sentiment Analysis Collect, clean and score tweets for sentiment analysis, from the search query to VADER scoring and weekly sentiment reports.](/blog/twitter-scraping/sentiment-analysis-dataset/)
-   [How to Build a Twitter Dataset for LLM and RAG Collect posts and threads, format them as JSON Lines with citation metadata, index them for retrieval and keep the dataset fresh.](/blog/twitter-scraping/llm-rag-dataset/)

![apidojo](/blog/authors/apidojo.png)

## [Apidojo](/blog/authors/apidojo/)

15+ years of experience in data retrieval.

API Dojo is always ready for you. With 15+ years of experience, data acquisition has never been that easy. Cheapest prices with high availability.

-   🏯 15+ years of experience in data retrieval.
-   💰 Cheapest prices, qualified data.
-   ⚙️ High availability, extreme maintenance.
-   🐉 Hyper communicative, excellent support.

-   [apify.com](https://apify.com/apidojo)
-   [x.com](https://x.com/apidojo_)
-   [github.com](https://github.com/apidojo-io)
