# X / Twitter Mentions & Keyword Monitor (`automly/x-twitter-mentions-keyword-monitor`) Actor

Monitor X (Twitter) for mentions of handles and keyword watchlists. Returns normalized posts with engagement metadata for brand monitoring, competitive intelligence, and social listening.

- **URL**: https://apify.com/automly/x-twitter-mentions-keyword-monitor.md
- **Developed by:** [Automly](https://apify.com/automly) (community)
- **Categories:** Social media
- **Stats:** 4 total users, 2 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## X / Twitter Mentions & Keyword Monitor

Monitor **X (Twitter)** for mentions of the handles you care about and for a
watchlist of keywords or phrases. Every matching public post is returned as a
clean, flat record with full engagement metadata — ready for brand monitoring,
competitive intelligence, lead signals, and social listening.

Point it at a set of handles and keywords, schedule it to run on an interval,
and build a continuously updated feed of who is talking about your brand,
products, competitors, or topics.

### What it does

- **Mention monitoring** — track public posts that mention one or more accounts.
- **Keyword & phrase watchlists** — track posts matching your terms; multi-word
  entries are matched as exact phrases.
- **Advanced queries** — power users can supply a raw search query with
  operators such as `from:`, `to:`, `filter:`, and `OR`.
- **Incremental runs** — a rolling "since minutes" window plus an automatic
  per-monitor checkpoint means scheduled runs pick up only what is new.
- **Normalized output** — consistent fields and engagement counts across every
  result, regardless of which monitor matched it.

### Input

| Field | Type | Description |
|-------|------|-------------|
| `handles` | array | Accounts to watch for mentions. Accepts `@handle`, bare handle, or profile URL. |
| `keywords` | array | Keywords or phrases to watch. Multi-word entries match as an exact phrase. |
| `query` | string | Optional raw advanced search query for power users. |
| `sort` | string | `latest` (newest first, best for monitoring) or `top` (most relevant). |
| `maxItems` | integer | Maximum posts to collect per run (1–2000). |
| `since` | string | Optional ISO date (`YYYY-MM-DD`); skip posts before it. |
| `until` | string | Optional ISO date (`YYYY-MM-DD`); skip posts on/after it. |
| `sinceMinutes` | integer | Optional rolling window in minutes; ideal for scheduled runs. |
| `includeReplies` | boolean | Include posts that are replies. Default `true`. |
| `includeRetweets` | boolean | Include reposts (retweets). Default `false`. |
| `language` | string | Optional ISO language code (e.g. `en`, `es`). |
| `authCookie` | string (secret) | Optional — your own logged-in X session cookie. |
| `authHeader` | string (secret) | Optional — custom Authorization header. |
| `bearerToken` | string (secret) | Optional — bearer token override. |
| `proxyConfiguration` | object | Proxy settings; residential proxies recommended. |

Provide at least one of `handles`, `keywords`, or `query`.

#### Example

```json
{
  "handles": ["@apify"],
  "keywords": ["web scraping", "data extraction"],
  "sort": "latest",
  "maxItems": 100,
  "sinceMinutes": 60,
  "includeReplies": true,
  "includeRetweets": false,
  "language": "en",
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
````

### Output

Each dataset item is one matched post:

| Field | Description |
|-------|-------------|
| `monitorType` / `monitorValue` | Which monitor matched (`mention` / `keyword` / `query`) and its value. |
| `tweetId` / `tweetUrl` | Post ID and direct URL. |
| `text` | Full post text. |
| `authorUsername` / `authorName` / `authorId` | Author identity. |
| `createdAt` / `language` | Creation timestamp (ISO 8601 UTC) and language. |
| `replyCount` / `repostCount` / `likeCount` / `quoteCount` / `viewCount` | Engagement metrics. |
| `isReply` / `isRepost` / `inReplyToTweetId` | Conversation context. |
| `mentionedUsers` / `hashtags` / `links` | Entities extracted from the post. |
| `fetchedAt` | When the record was collected (ISO 8601 UTC). |

### Important notes

- **Authentication.** Searching X reliably generally requires valid
  authenticated session details together with reliable proxy access. The actor
  accepts optional, securely-stored session fields you provide. Without them it
  makes a best-effort attempt and, if access is declined, finishes with a clear
  message and **no invented data** — you are not charged for empty results.
- **Scheduling.** Combine `sinceMinutes` with Apify's scheduler to keep a
  rolling, deduplicated feed up to date. The actor remembers the newest post it
  has seen for each monitor between runs.
- **Responsible use.** Only collect public data and respect X's Terms of
  Service and applicable laws and rate limits.

# Actor input Schema

## `handles` (type: `array`):

Accounts to watch for mentions. Accepts @handles (e.g. @nasa), bare handles (nasa), or profile URLs. Each becomes a search for public posts that mention the account.

## `keywords` (type: `array`):

Keywords or phrases to watch for. Multi-word entries are matched as an exact phrase. Combine with handles to build a full watchlist.

## `query` (type: `string`):

Optional raw X search query for power users (supports operators like from:, to:, filter:, OR). Used in addition to handles and keywords. Leave empty if not needed.

## `sort` (type: `string`):

How results are ordered. 'Latest' returns the newest posts first (best for monitoring); 'Top' returns the most relevant posts.

## `maxItems` (type: `integer`):

Maximum number of posts to collect across all monitors in a single run (1-2000).

## `since` (type: `string`):

Optional ISO date (YYYY-MM-DD). Posts created before this date are skipped. Ignored when 'Since minutes' is set.

## `until` (type: `string`):

Optional ISO date (YYYY-MM-DD). Posts created on or after this date are skipped.

## `sinceMinutes` (type: `integer`):

Optional. Only return posts from the last N minutes. Ideal for scheduled monitoring runs. Takes precedence over the 'since' date when set.

## `includeReplies` (type: `boolean`):

Include posts that are replies to other posts.

## `includeRetweets` (type: `boolean`):

Include reposts (retweets). When off, only original posts and quotes are returned.

## `language` (type: `string`):

Optional ISO language code to restrict results (e.g. 'en', 'es', 'pt'). Leave empty for all languages.

## `authCookie` (type: `string`):

Optional. Your own logged-in X session cookie string (must include the auth\_token and ct0 values). Searching X reliably generally requires authenticated session details. Provided by you and stored securely.

## `authHeader` (type: `string`):

Optional. A custom Authorization header value to send with requests. Most users can leave this empty.

## `bearerToken` (type: `string`):

Optional. A bearer token to use instead of the default web token. Most users can leave this empty.

## `proxyConfiguration` (type: `object`):

Proxy settings used to reach X reliably. Residential proxies are strongly recommended for consistent results.

## Actor input object example

```json
{
  "handles": [
    "@apify"
  ],
  "keywords": [
    "web scraping"
  ],
  "sort": "latest",
  "maxItems": 100,
  "includeReplies": true,
  "includeRetweets": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

All matched posts produced by this run.

## `overview` (type: `string`):

Dataset presented using the overview view from the dataset schema.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "handles": [
        "@apify"
    ],
    "keywords": [
        "web scraping"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("automly/x-twitter-mentions-keyword-monitor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "handles": ["@apify"],
    "keywords": ["web scraping"],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("automly/x-twitter-mentions-keyword-monitor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "handles": [
    "@apify"
  ],
  "keywords": [
    "web scraping"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call automly/x-twitter-mentions-keyword-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=automly/x-twitter-mentions-keyword-monitor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "X / Twitter Mentions & Keyword Monitor",
        "description": "Monitor X (Twitter) for mentions of handles and keyword watchlists. Returns normalized posts with engagement metadata for brand monitoring, competitive intelligence, and social listening.",
        "version": "1.0",
        "x-build-id": "Ji4jsZTyObr60GlO2"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/automly~x-twitter-mentions-keyword-monitor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-automly-x-twitter-mentions-keyword-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/automly~x-twitter-mentions-keyword-monitor/runs": {
            "post": {
                "operationId": "runs-sync-automly-x-twitter-mentions-keyword-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/automly~x-twitter-mentions-keyword-monitor/run-sync": {
            "post": {
                "operationId": "run-sync-automly-x-twitter-mentions-keyword-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "handles": {
                        "title": "Handles to monitor for mentions",
                        "type": "array",
                        "description": "Accounts to watch for mentions. Accepts @handles (e.g. @nasa), bare handles (nasa), or profile URLs. Each becomes a search for public posts that mention the account.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "keywords": {
                        "title": "Keywords / phrases to monitor",
                        "type": "array",
                        "description": "Keywords or phrases to watch for. Multi-word entries are matched as an exact phrase. Combine with handles to build a full watchlist.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "query": {
                        "title": "Advanced search query",
                        "type": "string",
                        "description": "Optional raw X search query for power users (supports operators like from:, to:, filter:, OR). Used in addition to handles and keywords. Leave empty if not needed."
                    },
                    "sort": {
                        "title": "Sort order",
                        "enum": [
                            "latest",
                            "top"
                        ],
                        "type": "string",
                        "description": "How results are ordered. 'Latest' returns the newest posts first (best for monitoring); 'Top' returns the most relevant posts.",
                        "default": "latest"
                    },
                    "maxItems": {
                        "title": "Max results",
                        "minimum": 1,
                        "maximum": 2000,
                        "type": "integer",
                        "description": "Maximum number of posts to collect across all monitors in a single run (1-2000).",
                        "default": 100
                    },
                    "since": {
                        "title": "Only posts since (date)",
                        "type": "string",
                        "description": "Optional ISO date (YYYY-MM-DD). Posts created before this date are skipped. Ignored when 'Since minutes' is set."
                    },
                    "until": {
                        "title": "Only posts until (date)",
                        "type": "string",
                        "description": "Optional ISO date (YYYY-MM-DD). Posts created on or after this date are skipped."
                    },
                    "sinceMinutes": {
                        "title": "Since minutes (rolling window)",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Optional. Only return posts from the last N minutes. Ideal for scheduled monitoring runs. Takes precedence over the 'since' date when set."
                    },
                    "includeReplies": {
                        "title": "Include replies",
                        "type": "boolean",
                        "description": "Include posts that are replies to other posts.",
                        "default": true
                    },
                    "includeRetweets": {
                        "title": "Include reposts",
                        "type": "boolean",
                        "description": "Include reposts (retweets). When off, only original posts and quotes are returned.",
                        "default": false
                    },
                    "language": {
                        "title": "Language",
                        "type": "string",
                        "description": "Optional ISO language code to restrict results (e.g. 'en', 'es', 'pt'). Leave empty for all languages."
                    },
                    "authCookie": {
                        "title": "Session cookie (optional)",
                        "type": "string",
                        "description": "Optional. Your own logged-in X session cookie string (must include the auth_token and ct0 values). Searching X reliably generally requires authenticated session details. Provided by you and stored securely."
                    },
                    "authHeader": {
                        "title": "Authorization header (optional)",
                        "type": "string",
                        "description": "Optional. A custom Authorization header value to send with requests. Most users can leave this empty."
                    },
                    "bearerToken": {
                        "title": "Bearer token (optional)",
                        "type": "string",
                        "description": "Optional. A bearer token to use instead of the default web token. Most users can leave this empty."
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Proxy settings used to reach X reliably. Residential proxies are strongly recommended for consistent results."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
