# Twitter Search Scraper (`powerai/twitter-search-scraper`) Actor

Search for tweets on Twitter by keyword, with support for Top, Latest, Media, Lists, and People search types. Auto-pagination and detailed tweet info.

- **URL**: https://apify.com/powerai/twitter-search-scraper.md
- **Developed by:** [PowerAI](https://apify.com/powerai) (community)
- **Categories:** Social media
- **Stats:** 511 total users, 12 monthly users, 99.6% runs succeeded, 17 bookmarks
- **User rating**: 3.20 out of 5 stars

## Pricing

from $4.99 / 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.

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 Search Scraper

This actor allows you to search for tweets on Twitter using a keyword or phrase. It supports different search types (Top, Latest, Media, People, Lists) and automatic pagination to collect up to the number of tweets you specify.

### Features

- Search for tweets by keyword or phrase.
- Supports search types: Top, Latest, Media, People.
- Automatic pagination to retrieve large result sets.
- Specify the maximum number of results (`maxResults`).
- Returns detailed information for each tweet.

### Input

- **query** (string, required): The search keyword or phrase.
- **searchType** (string, optional): Type of search result to fetch. One of `Top`, `Latest`, `Media`, `People`, `Lists`. Default is `Top`.
- **maxResults** (integer, optional): Maximum number of tweets to fetch. Default is 15.

### Output

The output is an array of tweet objects, each containing:

- `tweet_id`
- `screen_name`
- `favorites`
- `created_at`
- `text`
- `lang`
- `source`
- `quotes`
- `replies`
- `retweets`
- `views`
- `entities`
- `user_info`
- `media`

### Example Input

```json
{
  "query": "OpenAI",
  "searchType": "Top",
  "maxResults": 15
}
```

### Example Output

```json
[
	{
		"type": "tweet",
		"tweet_id": "1928111107706868204",
		"screen_name": "ronakkadhi",
		"bookmarks": 166,
		"favorites": 101,
		"created_at": "Thu May 29 15:28:05 +0000 2025",
		"text": "OpenAI quietly dropped a full guide on how to build AI agents from scratch.\n\nMost people won’t read it. I did. Twice.\n\nThis thread breaks it down into a tactical playbook for founders, builders, and operators.\n\nA fast-track guide to building real AI agents🧵 https://t.co/Rr2vhG2bP0",
		"lang": "en",
		"source": "<a href=\"https://typefully.com/\" rel=\"nofollow\">Typefully</a>",
		"quotes": 1,
		"replies": 2,
		"conversation_id": "1928111107706868204",
		"retweets": 38,
		"views": "16364",
		"entities": {
			"hashtags": [],
			"media": [
				{
					"display_url": "pic.x.com/Rr2vhG2bP0",
					"expanded_url": "https://x.com/ronakkadhi/status/1928111107706868204/photo/1",
					"id_str": "1928111101520269315",
					"indices": [
						258,
						281
					],
					"media_key": "3_1928111101520269315",
					"media_url_https": "https://pbs.twimg.com/media/GsIG1M2aUAMLBLg.jpg",
					"type": "photo",
					"url": "https://t.co/Rr2vhG2bP0",
					"ext_media_availability": {
						"status": "Available"
					},
					"features": {
						"large": {
							"faces": [
								{
									"x": 423,
									"y": 140,
									"h": 237,
									"w": 237
								}
							]
						},
						"medium": {
							"faces": [
								{
									"x": 423,
									"y": 140,
									"h": 237,
									"w": 237
								}
							]
						},
						"small": {
							"faces": [
								{
									"x": 239,
									"y": 79,
									"h": 134,
									"w": 134
								}
							]
						},
						"orig": {
							"faces": [
								{
									"x": 423,
									"y": 140,
									"h": 237,
									"w": 237
								}
							]
						}
					},
					"sizes": {
						"large": {
							"h": 800,
							"w": 1200,
							"resize": "fit"
						},
						"medium": {
							"h": 800,
							"w": 1200,
							"resize": "fit"
						},
						"small": {
							"h": 453,
							"w": 680,
							"resize": "fit"
						},
						"thumb": {
							"h": 150,
							"w": 150,
							"resize": "crop"
						}
					},
					"original_info": {
						"height": 800,
						"width": 1200,
						"focus_rects": [
							{
								"x": 0,
								"y": 0,
								"w": 1200,
								"h": 672
							},
							{
								"x": 170,
								"y": 0,
								"w": 800,
								"h": 800
							},
							{
								"x": 219,
								"y": 0,
								"w": 702,
								"h": 800
							},
							{
								"x": 370,
								"y": 0,
								"w": 400,
								"h": 800
							},
							{
								"x": 0,
								"y": 0,
								"w": 1200,
								"h": 800
							}
						]
					},
					"media_results": {
						"result": {
							"media_key": "3_1928111101520269315"
						}
					}
				},
				{
					"display_url": "pic.x.com/Rr2vhG2bP0",
					"expanded_url": "https://x.com/ronakkadhi/status/1928111107706868204/photo/1",
					"id_str": "1928111105479692291",
					"indices": [
						258,
						281
					],
					"media_key": "3_1928111105479692291",
					"media_url_https": "https://pbs.twimg.com/media/GsIG1bmaUAMEYRX.png",
					"type": "photo",
					"url": "https://t.co/Rr2vhG2bP0",
					"ext_media_availability": {
						"status": "Available"
					},
					"features": {
						"large": {
							"faces": []
						},
						"medium": {
							"faces": []
						},
						"small": {
							"faces": []
						},
						"orig": {
							"faces": []
						}
					},
					"sizes": {
						"large": {
							"h": 805,
							"w": 1020,
							"resize": "fit"
						},
						"medium": {
							"h": 805,
							"w": 1020,
							"resize": "fit"
						},
						"small": {
							"h": 537,
							"w": 680,
							"resize": "fit"
						},
						"thumb": {
							"h": 150,
							"w": 150,
							"resize": "crop"
						}
					},
					"original_info": {
						"height": 805,
						"width": 1020,
						"focus_rects": [
							{
								"x": 0,
								"y": 0,
								"w": 1020,
								"h": 571
							},
							{
								"x": 183,
								"y": 0,
								"w": 805,
								"h": 805
							},
							{
								"x": 232,
								"y": 0,
								"w": 706,
								"h": 805
							},
							{
								"x": 384,
								"y": 0,
								"w": 403,
								"h": 805
							},
							{
								"x": 0,
								"y": 0,
								"w": 1020,
								"h": 805
							}
						]
					},
					"media_results": {
						"result": {
							"media_key": "3_1928111105479692291"
						}
					}
				}
			],
			"symbols": [],
			"timestamps": [],
			"urls": [],
			"user_mentions": []
		},
		"user_info": {
			"screen_name": "ronakkadhi",
			"name": "Ronak Kadhi",
			"created_at": "Sun May 13 13:06:18 +0000 2018",
			"description": "Building an AI designer at https://t.co/qvfuOVGxKx Tweeting about AI, Design and Marketing as I see it",
			"rest_id": "995651450620522496",
			"followers_count": 4254,
			"favourites_count": 1279,
			"avatar": "https://pbs.twimg.com/profile_images/995655731800981505/iG8sWGBw_normal.jpg",
			"verified": true,
			"friends_count": 1016,
			"location": null
		},
		"media": {
			"photo": [
				{
					"media_url_https": "https://pbs.twimg.com/media/GsIG1M2aUAMLBLg.jpg",
					"id": "1928111101520269315",
					"sizes": {
						"h": 800,
						"w": 1200
					}
				},
				{
					"media_url_https": "https://pbs.twimg.com/media/GsIG1bmaUAMEYRX.png",
					"id": "1928111105479692291",
					"sizes": {
						"h": 805,
						"w": 1020
					}
				}
			]
		},
		"scrapedAt": "2025-05-30T02:20:28.921Z"
	},
	...
]
```

### Notes

- The actor will stop fetching once it reaches the specified `maxResults` or there are no more tweets to fetch.
- Make sure your search query complies with Twitter's search policies.

# Actor input Schema

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

The search keyword or phrase.

## `searchType` (type: `string`):

Type of search result to fetch.

## `maxResults` (type: `integer`):

Maximum number of tweets to fetch.

## Actor input object example

```json
{
  "query": "OpenAI",
  "searchType": "Top",
  "maxResults": 15
}
```

# 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 = {
    "query": "OpenAI",
    "maxResults": 15
};

// Run the Actor and wait for it to finish
const run = await client.actor("powerai/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 = {
    "query": "OpenAI",
    "maxResults": 15,
}

# Run the Actor and wait for it to finish
run = client.actor("powerai/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 '{
  "query": "OpenAI",
  "maxResults": 15
}' |
apify call powerai/twitter-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,powerai/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/TzcgQa7ZXU5J9UcN3/builds/jYtbcbbwiHlS1W103/openapi.json
