# Twitter (X) Search Scraper - Tweets by Keyword, $0.40/1k (`dami_studio/twitter-search-scraper`) Actor

Search Twitter (X) for tweets by keyword. X only serves search results to a signed-in session, so this Actor brings its own. Advanced queries work: from:, min\_faves:, filter:media and dates. Each tweet has the text, likes, retweets, replies, views, media and author. $0.40 per 1,000 tweets.

- **URL**: https://apify.com/dami\_studio/twitter-search-scraper.md
- **Developed by:** [Dami's Studio](https://apify.com/dami_studio) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 62 total users, 27 monthly users, 83.1% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## Twitter (X) Search Scraper — tweets by keyword

Put in a search query, get back the tweets. Full text, likes, retweets, replies, quotes, bookmarks,
views, media, and the author with their bio and follower counts attached. X's advanced operators all
work — `from:`, `to:`, `min_faves:`, `filter:media`, `-filter:replies`, `lang:`, quoted phrases.

You don't need to log in, register a developer account, or go and find a cookie. Which needs
explaining, because search is the one thing on X that genuinely can't be done signed out.

### Where the session comes from

X does not serve search to a guest token. The identical request that returns a full profile with no
credentials returns an empty payload for a search. Rotating addresses doesn't help. Nor does a
cleaner browser fingerprint. The endpoint is closed to callers who aren't signed in.

So the actor carries its own logged-in session and uses it on your behalf. **No login is needed from
you**, but it isn't accurate to call this a keyless scrape, and it would be dishonest to imply
nothing is signed in. Something is: an account we run.

**That session is shared with everyone else using this actor, and X counts rate limits per account
rather than per caller.** Under heavy concurrent load it throttles, and your run can come back short
or with a `BLOCKED` diagnostic row saying why. That's the trade for not having to set anything up.

If you're pulling at volume, or you just don't want your throughput tied to how busy the actor is,
put your own cookie in `sessionCookies` and the run uses only yours — a rate limit nobody else draws
on. Your cookies are never mixed with the built-in one.

**Getting your own cookie takes about a minute:**

1. Log in to **x.com** (a throwaway account is fine, and a sensible choice).
2. **F12** → **Application** → **Cookies** → `https://x.com`.
3. Copy the values of `auth_token` and `ct0`.
4. Paste as `auth_token=XXXX; ct0=YYYY` into `sessionCookies`. One account per line — several lines
   are rotated, and one going quiet doesn't stop the run.

### What each row looks like

```json
{
  "ok": true,
  "charged": true,
  "id": "2090836814202388875",
  "url": "https://x.com/handle/status/2090836814202388875",
  "text": "the full tweet text, not truncated",
  "createdAt": "Fri Aug 21 16:21:57 +0000 2026",
  "lang": "en",
  "replyCount": 0,
  "retweetCount": 0,
  "likeCount": 0,
  "quoteCount": 0,
  "bookmarkCount": 0,
  "viewCount": null,
  "isReply": true,
  "isRetweet": false,
  "isQuote": true,
  "conversationId": "2090836139414364439",
  "inReplyToId": "2090836539211214939",
  "inReplyToUser": "handle",
  "hashtags": [],
  "mentions": [],
  "urls": ["https://x.com/OpenAI/status/2090165329867743501"],
  "media": [],
  "author": {
    "id": "82559544",
    "userName": "handle",
    "name": "Display Name",
    "description": "the account bio",
    "followersCount": 1591,
    "friendsCount": 489,
    "statusesCount": 2910,
    "verified": true,
    "isBlueVerified": true
  }
}
```

The author object is filled in on this route, so you get follower counts without a second lookup.
`viewCount` is `null` on tweets where X doesn't publish it — usually very new or very small ones.

### Input

```json
{
  "searchTerms": ["\"open source\" min_faves:50 -filter:replies"],
  "sort": "Latest",
  "maxItems": 100,
  "since": "2026-08-01"
}
```

| Field | Default | Notes |
|---|---|---|
| `searchTerms` | — | One or more X search queries. Advanced operators behave exactly as they do on x.com. |
| `sort` | `Latest` | `Latest` for newest first, `Top` for X's relevance ranking. |
| `maxItems` | `100` | 1 to 5,000 per run. This is your spend cap. |
| `since` / `until` | — | `YYYY-MM-DD` bounds, folded into the query. |
| `onlyVerifiedUsers` | `false` | Keep only verified authors. Filtered-out tweets aren't charged. |
| `sessionCookies` | — | Optional. `auth_token=…; ct0=…`, one account per line. Stored as a secret. |
| `proxyConfiguration` | Apify datacenter | Leave it. Traffic goes out over rented static addresses with rotating Apify datacenter behind them; neither is billed by the gigabyte. Metered groups like `RESIDENTIAL` aren't offered and are swapped for datacenter if you ask. Your own servers in `proxyUrls` are used exactly as given. |
| `notionConnector` / `notionParentId` | — | Optional: write each tweet into a Notion database too. |

### Limits

- **Search walks up to 100 pages per term.** A wide query with a distant `since` date can exhaust
  that budget before it reaches your window; the run logs how far back it got.
- **Tweets are deduplicated by id** across all your search terms, so the same tweet is never
  returned or charged twice in one run.
- **If every session in the pool is exhausted**, the run still succeeds. It returns a single clearly
  labelled `_sample` row so you can see the output shape, and no per-tweet fee is charged for it.
  A dead cookie is dropped for the rest of the run and the next one is tried.
- **A transient upstream failure is retried, not reported as "no results".** X occasionally answers
  a perfectly valid search with a 404 or a 5xx. Those are retried, from a different exit address,
  before a term is given up on. If every attempt on every term still fails, the run **fails** with
  the reason instead of finishing as a success with no rows -- nothing is charged either way, so a
  failed run costs you nothing and can simply be re-run.
- X's search index doesn't go back forever, and it isn't exhaustive. That's X's behaviour, not the
  actor's. Run the same query in a browser and you get the same set back.

### Billing

**$0.0004 per tweet returned ($0.40 per 1,000).** Flat on every Apify plan, no volume tiers.

Everything else is free: sample rows, diagnostic rows, tweets your filters removed, duplicates, and
a search that comes back with nothing.

# Actor input Schema

## `searchTerms` (type: `array`):

X search queries (advanced operators supported).

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

Latest gives you the newest tweets in the window. Top gives you what X ranks as most relevant, which skews to popular accounts.

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

Only tweets posted on or after this date, as YYYY-MM-DD. Leave empty for no lower bound.

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

Only tweets posted on or before this date, as YYYY-MM-DD. Leave empty to run up to now.

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

Hard cap on tweets returned. You are charged per tweet, so this is also your budget for the run.

## `onlyVerifiedUsers` (type: `boolean`):

Keep only verified authors.

## `notionConnector` (type: `string`):

Optional Notion delivery.

## `notionParentId` (type: `string`):

Optional Notion data-source id.

## `sessionCookies` (type: `array`):

Optional. Runs use a built-in session by default, and that session is shared, so under heavy concurrent load it is rate-limited across everyone using it. Supply your own account cookie here and the run uses only yours, giving you a rate limit nobody else draws on. In Chrome, logged in to x.com: F12 -> Application -> Cookies -> https://x.com, and copy auth\_token and ct0. Paste one account per line as 'auth\_token=XXXX; ct0=YYYY'. Several lines means several accounts, rotated. Stored as a secret and never logged.

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

Optional. By default the Actor goes out through its own rented static addresses (flat rate, unmetered) with rotating Apify datacenter as the fallback — you pay nothing extra for either. Metered groups (RESIDENTIAL) are not offered and are replaced with datacenter if requested. To use your own proxy servers, put them in proxyUrls; those are passed through untouched.

## Actor input object example

```json
{
  "searchTerms": [
    "\"web scraping\" min_faves:50",
    "from:nasa"
  ],
  "sort": "Latest",
  "since": "2024-01-01",
  "until": "2024-12-31",
  "maxItems": 100,
  "onlyVerifiedUsers": false,
  "sessionCookies": [
    "auth_token=abcd1234...; ct0=ef567890..."
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

Tweets in the default dataset.

# 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 = {
    "searchTerms": [
        "apify"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dami_studio/twitter-search-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 = { "searchTerms": ["apify"] }

# Run the Actor and wait for it to finish
run = client.actor("dami_studio/twitter-search-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 '{
  "searchTerms": [
    "apify"
  ]
}' |
apify call dami_studio/twitter-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dami_studio/twitter-search-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/L2zqKAajeIF8uk7ej/builds/6TpM013kYcJiu9gzO/openapi.json
