# Twitter Scraper - Search Tweets by Keyword (`toolzerhub/twitter-scraper`) Actor

Search Twitter (X) by keyword, hashtag or advanced operators like from:, since: and min_faves:, and export every matching tweet. Each row has the text, time, likes, reposts, replies, views, author and media. Run many searches at once and sort by latest or top.

- **URL**: https://apify.com/toolzerhub/twitter-scraper.md
- **Developed by:** [ToolzerHub](https://apify.com/toolzerhub) (community)
- **Categories:** Social media, Marketing, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.08 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Twitter Scraper — Search Tweets by Keyword

Search Twitter (X) by keyword, hashtag or advanced operator and export every matching tweet — text, timestamp, language, likes, reposts, replies, quotes, bookmarks, views, author and attached media — as one row per tweet.

Give it one query or fifty. Each runs in turn, newest first or most engaged first, until you hit your cap or the results run out.

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| **`searchQueries`** | list of text | — | **Required.** One or more searches. Operators go inside the text. |
| **`sort`** | `latest` / `top` | `latest` | `latest` is newest first. `top` is the most engaged first. |
| **`maxItems`** | integer | `100` | Caps the whole run, across every query. `0` means no limit. |

```json
{
  "searchQueries": ["from:openai", "openai lang:en"],
  "sort": "top",
  "maxItems": 100
}
```

Operators you can put in a query:

| Operator | Matches |
|---|---|
| `from:handle` | Tweets written by that account |
| `"exact phrase"` | The phrase, word for word |
| `#hashtag` | Tweets carrying the hashtag |
| `lang:en` | Tweets X detected as English |
| `min_faves:100` | Tweets with at least 100 likes |
| `since:2026-10-01` `until:2026-10-15` | A date window |
| `-filter:replies` | Everything except replies |
| `(a OR b)` | Either term. Every `(` needs its `)`. |

### Output

One row per tweet.

| Field | What it holds |
|---|---|
| **`id`**, **`url`** | The tweet's ID and its link on x.com |
| **`text`**, **`lang`** | What it says, and the language X detected |
| **`created_at`** | Publish time, ISO 8601 UTC |
| **`like_count`**, **`reply_count`**, **`repost_count`**, **`quote_count`**, **`bookmark_count`**, **`view_count`** | The six counters, as they read when the tweet was fetched |
| **`author_handle`**, **`author_name`**, **`author_id`**, **`author_followers_count`**, **`author_is_blue_verified`** | The author, flattened for spreadsheets |
| **`author`** | The author's full profile record |
| **`media`**, **`hashtags`**, **`mentions`**, **`urls`**, **`card`**, **`article`**, **`place`** | Photos, videos and GIFs, hashtags, mentioned accounts, links with their destinations, link card, attached article, tagged place |
| **`is_reply`**, **`in_reply_to_post_id`**, **`in_reply_to_handle`**, **`conversation_id`** | Where the tweet sits in a thread |
| **`quoted_post`**, **`reposted_post`** | The tweet it quotes, or the original it reposts |
| **`input_query`** | The query that found it, so several searches can share one dataset |

```json
{
  "id": "2110399768232898915",
  "url": "https://x.com/zerohedge/status/2110399768232898915",
  "text": "*OPENAI COMPUTING CHIEF TO DEPART: WSJ",
  "lang": "en",
  "source": "Twitter for iPhone",
  "created_at": "2026-10-14T15:58:08.000Z",
  "like_count": 881,
  "reply_count": 39,
  "repost_count": 57,
  "quote_count": 28,
  "view_count": 175617,
  "bookmark_count": 52,
  "is_reply": false,
  "in_reply_to_post_id": null,
  "in_reply_to_user_id": null,
  "in_reply_to_handle": null,
  "conversation_id": "2110399768232898915",
  "is_pinned": null,
  "hashtags": [],
  "author_id": "18856867",
  "author_handle": "zerohedge",
  "author_name": "zerohedge",
  "author_followers_count": 3432237,
  "author_is_blue_verified": true,
  "input_query": "openai lang:en"
}
```

The `author`, `media`, `quoted_post`, `reposted_post` and the other nested fields are cut from this example to keep it short. They are in every row.

### Pricing

You pay for each tweet saved. A tweet that is skipped is never charged.

| Plan | Per 1,000 tweets |
|---|---|
| Free | $2.00 |
| Bronze | $1.69 |
| Silver | $1.38 |
| Gold and above | $1.08 |

Each run also carries a $0.00005 start charge. The Free plan covers the first 50 rows you save with this Actor; after that you need a paid plan.

### Questions

**Why did I get fewer tweets than `maxItems`?**
A query stops when X stops returning pages for it or returns an empty one. Broad queries get cut off well before they run dry. Split them into date windows — `since:` and `until:` — and give each its own entry in `searchQueries`.

**Does `maxItems` apply per query or to the whole run?**
The whole run, in the order you list the queries. A busy first query can use the entire budget. Put the one you care about first, or run the queries separately.

**What do `latest` and `top` change?**
`latest` walks back from the newest tweet and goes as far as X lets it. `top` ranks by engagement and usually ends sooner. Use `latest` for monitoring and `top` for "what did people react to".

**A row's `text` starts with "RT @". Where is the full tweet?**
In `reposted_post`. On a repost, `text` is X's shortened form. A quote tweet keeps its own text, and the tweet it quotes sits in `quoted_post`.

**What happens to a query X rejects?**
It is skipped, and the log says why — an unbalanced parenthesis is one cause. Other queries in the list still run. If every query is rejected, the run fails with that reason and nothing is charged.

**Can I run this from code or on a schedule?**
Yes. Any Apify client works, and Apify's scheduler can run it hourly or daily:

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("toolzerhub/twitter-scraper").call(
    run_input={"searchQueries": ["from:openai"], "maxItems": 50}
)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["created_at"], row["text"])
```

**Are the counters exact?**
They are live numbers. Two runs a few minutes apart will disagree on likes and views. That is drift, not a fault.

### Related Actors

| Actor | Use it when |
|---|---|
| [Twitter Tweets Scraper](https://apify.com/toolzerhub/twitter-tweets-scraper) | You want one account's own timeline rather than a search |
| [Twitter Comments Scraper](https://apify.com/toolzerhub/twitter-comments-scraper) | You already have a tweet and want the replies under it |
| [Twitter Profile Scraper](https://apify.com/toolzerhub/twitter-profile-scraper) | You need the full profile behind an `author_handle` |
| [Twitter Followers Scraper](https://apify.com/toolzerhub/twitter-followers-scraper) | You want the accounts that follow an author |

### Support

Questions, bugs, or feature requests: **contact@toolzerhub.com**

Browse the rest: [apify.com/toolzerhub](https://apify.com/toolzerhub)

# Actor input Schema

## `searchQueries` (type: `array`):

One or more searches, run one after another. Plain words work, and so do X's search operators: `from:openai`, `"exact phrase"`, `#hashtag`, `since:2026-10-01`, `until:2026-10-15`, `min_faves:100`, `lang:en`, `-filter:replies`.

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

`Latest` returns the newest posts first. `Top` returns the posts with the most engagement.

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

Most rows to save in this run, across everything in the list. Set 0 for no limit.

## Actor input object example

```json
{
  "searchQueries": [
    "from:openai"
  ],
  "sort": "latest",
  "maxItems": 50
}
```

# Actor output Schema

## `dataset` (type: `string`):

Every record collected during this run

# 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 = {
    "searchQueries": [
        "from:openai"
    ],
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("toolzerhub/twitter-scraper").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 = {
    "searchQueries": ["from:openai"],
    "maxItems": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("toolzerhub/twitter-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "from:openai"
  ],
  "maxItems": 50
}' |
apify call toolzerhub/twitter-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,toolzerhub/twitter-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/tOqrUauY5hmLTMiRQ/builds/xYdGIr4dxNzs13MAi/openapi.json
