# Twitter Communities Top Posts Scraper (`powerai/twitter-communities-top-posts-scraper`) Actor

Fetch the top posts from Twitter communities by keyword, with auto-pagination and detailed post info. Supports up to your specified maxResults.

- **URL**: https://apify.com/powerai/twitter-communities-top-posts-scraper.md
- **Developed by:** [PowerAI](https://apify.com/powerai) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 14 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## 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/platform/actors/running/actors-in-store#pay-per-event

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

## 🐦 Twitter Communities Top Posts Scraper

This actor allows you to fetch the top posts from Twitter communities based on a search keyword or phrase. It uses the latest Twitter API interface and supports automatic pagination to collect up to the number of posts you specify.

### Features

- Fetches the top posts from Twitter communities by keyword.
- Supports automatic pagination to retrieve large lists.
- Allows you to specify the maximum number of results (`maxResults`).
- Returns detailed information for each post.

### Input

- **query** (string, required): The keyword or phrase to search for in Twitter communities.
- **maxResults** (integer, optional): Maximum number of community posts to fetch. Default is 20.

### Output

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

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

### Example Input

```json
{
  "query": "AI",
  "maxResults": 20
}
````

### Example Output

```json
[
	{
		"type": "tweet",
		"tweet_id": "1919031648391176434",
		"screen_name": "buwungkepin",
		"bookmarks": 9503,
		"favorites": 66550,
		"created_at": "Sun May 04 14:09:33 +0000 2025",
		"text": "AI BISA DIHAPUS AJA GA SI? SUMPAH INI GUA JADI KERJA 2X GARA GARA TEMEN GUA PAKE AI BUAT PEMBAHASAN MAKALAH. AH TAI LAH CAPE AJGG. JURNAL PUN PAKE AI???? BABI. https://t.co/Dhbnwk9w9r",
		"lang": "in",
		"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
		"conversation_id": "1919031648391176434",
		"possibly_sensitive": false,
		"edit_tweet_ids": null,
		"geo": null,
		"limited_actions": null,
		"in_reply_to_user_id": null,
		"in_reply_to": null,
		"quoted_from": null,
		"community_id": "1562271278744354816",
		"author_id": "1540299945647165440",
		"quotes": 3225,
		"replies": 1488,
		"retweets": 4965,
		"views": "7519017",
		"entities": {
			"hashtags": [],
			"media": [
				{
					"display_url": "pic.x.com/Dhbnwk9w9r",
					"expanded_url": "https://x.com/buwungkepin/status/1919031648391176434/photo/1",
					"id_str": "1919031635401707520",
					"indices": [
						160,
						183
					],
					"media_key": "3_1919031635401707520",
					"media_url_https": "https://pbs.twimg.com/media/GqHFGtzbEAAH_dX.jpg",
					"type": "photo",
					"url": "https://t.co/Dhbnwk9w9r",
					"ext_media_availability": {
						"status": "Available"
					},
					"features": {
						"large": {
							"faces": [
								{
									"x": 36,
									"y": 657,
									"h": 50,
									"w": 50
								}
							]
						},
						"medium": {
							"faces": [
								{
									"x": 36,
									"y": 657,
									"h": 50,
									"w": 50
								}
							]
						},
						"small": {
							"faces": [
								{
									"x": 23,
									"y": 437,
									"h": 33,
									"w": 33
								}
							]
						},
						"orig": {
							"faces": [
								{
									"x": 36,
									"y": 657,
									"h": 50,
									"w": 50
								}
							]
						}
					},
					"sizes": {
						"large": {
							"h": 1021,
							"w": 499,
							"resize": "fit"
						},
						"medium": {
							"h": 1021,
							"w": 499,
							"resize": "fit"
						},
						"small": {
							"h": 680,
							"w": 332,
							"resize": "fit"
						},
						"thumb": {
							"h": 150,
							"w": 150,
							"resize": "crop"
						}
					},
					"original_info": {
						"height": 1021,
						"width": 499,
						"focus_rects": [
							{
								"x": 0,
								"y": 742,
								"w": 499,
								"h": 279
							},
							{
								"x": 0,
								"y": 522,
								"w": 499,
								"h": 499
							},
							{
								"x": 0,
								"y": 452,
								"w": 499,
								"h": 569
							},
							{
								"x": 0,
								"y": 23,
								"w": 499,
								"h": 998
							},
							{
								"x": 0,
								"y": 0,
								"w": 499,
								"h": 1021
							}
						]
					},
					"media_results": {
						"result": {
							"media_key": "3_1919031635401707520"
						}
					}
				},
				{
					"display_url": "pic.x.com/Dhbnwk9w9r",
					"expanded_url": "https://x.com/buwungkepin/status/1919031648391176434/photo/1",
					"id_str": "1919031644436197376",
					"indices": [
						160,
						183
					],
					"media_key": "3_1919031644436197376",
					"media_url_https": "https://pbs.twimg.com/media/GqHFHPdacAAvJNw.jpg",
					"type": "photo",
					"url": "https://t.co/Dhbnwk9w9r",
					"ext_media_availability": {
						"status": "Available"
					},
					"features": {
						"large": {
							"faces": [
								{
									"x": 676,
									"y": 450,
									"h": 114,
									"w": 114
								},
								{
									"x": 18,
									"y": 512,
									"h": 700,
									"w": 700
								}
							]
						},
						"medium": {
							"faces": [
								{
									"x": 396,
									"y": 263,
									"h": 66,
									"w": 66
								},
								{
									"x": 10,
									"y": 300,
									"h": 410,
									"w": 410
								}
							]
						},
						"small": {
							"faces": [
								{
									"x": 224,
									"y": 149,
									"h": 37,
									"w": 37
								},
								{
									"x": 5,
									"y": 170,
									"h": 232,
									"w": 232
								}
							]
						},
						"orig": {
							"faces": [
								{
									"x": 676,
									"y": 450,
									"h": 114,
									"w": 114
								},
								{
									"x": 18,
									"y": 512,
									"h": 700,
									"w": 700
								}
							]
						}
					},
					"sizes": {
						"large": {
							"h": 2048,
							"w": 1542,
							"resize": "fit"
						},
						"medium": {
							"h": 1200,
							"w": 904,
							"resize": "fit"
						},
						"small": {
							"h": 680,
							"w": 512,
							"resize": "fit"
						},
						"thumb": {
							"h": 150,
							"w": 150,
							"resize": "crop"
						}
					},
					"original_info": {
						"height": 2048,
						"width": 1542,
						"focus_rects": [
							{
								"x": 0,
								"y": 233,
								"w": 1542,
								"h": 864
							},
							{
								"x": 0,
								"y": 0,
								"w": 1542,
								"h": 1542
							},
							{
								"x": 0,
								"y": 0,
								"w": 1542,
								"h": 1758
							},
							{
								"x": 255,
								"y": 0,
								"w": 1024,
								"h": 2048
							},
							{
								"x": 0,
								"y": 0,
								"w": 1542,
								"h": 2048
							}
						]
					},
					"media_results": {
						"result": {
							"media_key": "3_1919031644436197376"
						}
					}
				}
			],
			"symbols": [],
			"timestamps": [],
			"urls": [],
			"user_mentions": []
		},
		"user_info": {
			"id": "1540299945647165440",
			"screen_name": "buwungkepin",
			"verified": false,
			"protected": null,
			"pinned_tweet_id": "1927048239045373990",
			"name": "#JusticeForArgo",
			"withheld": [],
			"description": "fiat justitia ruat caelum\n#JusticeForArgo",
			"entities": {
				"description": {
					"urls": []
				}
			},
			"location": "",
			"followers_count": 1785,
			"favourites_count": 2116,
			"profile_image_url": null,
			"friends_count": 26,
			"created_at": "Fri Jun 24 11:45:17 +0000 2022"
		},
		"media": {
			"photo": [
				{
					"media_url_https": "https://pbs.twimg.com/media/GqHFGtzbEAAH_dX.jpg",
					"id": "1919031635401707520"
				},
				{
					"media_url_https": "https://pbs.twimg.com/media/GqHFHPdacAAvJNw.jpg",
					"id": "1919031644436197376"
				}
			]
		},
		"scrapedAt": "2025-05-30T03:36:00.900Z"
	},
	...
]
```

### Notes

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

# Actor input Schema

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

The keyword or phrase to search for in Twitter communities.

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

Maximum number of community posts to fetch.

## Actor input object example

```json
{
  "query": "AI",
  "maxResults": 20
}
```

# 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": "AI",
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("powerai/twitter-communities-top-posts-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": "AI",
    "maxResults": 20,
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=powerai/twitter-communities-top-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Twitter Communities Top Posts Scraper",
        "description": "Fetch the top posts from Twitter communities by keyword, with auto-pagination and detailed post info. Supports up to your specified maxResults.",
        "version": "0.0",
        "x-build-id": "zgGWjMXZxeyBMjJRC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/powerai~twitter-communities-top-posts-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-powerai-twitter-communities-top-posts-scraper",
                "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/powerai~twitter-communities-top-posts-scraper/runs": {
            "post": {
                "operationId": "runs-sync-powerai-twitter-communities-top-posts-scraper",
                "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/powerai~twitter-communities-top-posts-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-powerai-twitter-communities-top-posts-scraper",
                "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",
                "required": [
                    "query"
                ],
                "properties": {
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "The keyword or phrase to search for in Twitter communities.",
                        "default": "AI"
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 20,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Maximum number of community posts to fetch.",
                        "default": 20
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
