# Twitter Posts Scraper (`pratikdani/twitter-posts-scraper`) Actor

The **Twitter Posts Scraper** extracts detailed information from any public Twitter post. Simply provide the URL, and the scraper will gather data like post text, user info, engagement metrics, and more. Perfect for analyzing trends and tracking social media interactions.

- **URL**: https://apify.com/pratikdani/twitter-posts-scraper.md
- **Developed by:** [Pratik Dani](https://apify.com/pratikdani) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 838 total users, 29 monthly users, 100.0% runs succeeded, 14 bookmarks
- **User rating**: 1.00 out of 5 stars

## Pricing

from $15.00 / 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?

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

Interested in using this scraper? Get it here: [Twitter Posts Scraper](https://apify.com/pratikdani/twitter-posts-scraper). Scrape Twitter posts and extract detailed information in bulk.

### Features

**Comprehensive Data Extraction:** Extract detailed data from Twitter posts including text content, user information, engagement metrics, and media attachments. This allows for a complete analysis of the posts' reach and user interaction.

**Data Export and Integration:** Once the scraping process is complete, you can easily export the extracted data in various formats such as JSON, CSV, or Excel. You can select the fields you want, allowing for seamless integration with other tools and platforms for further analysis and utilization.

**Automatic Retry and Error Handling:** In case of temporary issues like network failures or timeouts, the scraper has built-in automatic retry functionality. It intelligently handles errors to ensure a smooth and uninterrupted scraping experience.

**Ability to Resume Last Failed Runs:** In case of unexpected errors, you can simply go to the scraper's last run page and click on the 'Resurrect' button to resume the last scraping progress.

### Sample Output

Here is a sample output of this scraper:

```json
{
  "biography": "Here we go! © fabrizio.romano93@gmail.com 📩",
  "bookmarks": 756,
  "date_posted": "2023-07-24T19:26:23.000Z",
  "description": "Here we go? Al Hilal you can take me. I look like Kylian Mbappe",
  "external_url": null,
  "followers": 21754744,
  "following": 2583,
  "hashtags": null,
  "id": "1683559267524136962",
  "input": {
    "url": "https://x.com/FabrizioRomano/status/1683559267524136962/"
  },
  "is_verified": false,
  "likes": 259030,
  "name": "Fabrizio Romano",
  "photos": null,
  "posts_count": 46594,
  "profile_image_link": "https://pbs.twimg.com/profile_images/1741753635158024192/j0m8Ucvv_normal.jpg",
  "quoted_post": {
    "date_posted": null,
    "description": "Al Hilal you can take me. I look like Kylian Mbappe 😂😂👀 https://t.co/VH0syez3VX",
    "photos": [
      "https://pbs.twimg.com/media/F10rS33WwAAJOQo.jpg"
    ],
    "post_id": "1683549442287255552",
    "profile_id": "Giannis_An34",
    "profile_name": "Giannis Antetokounmpo",
    "url": "https://x.com/Giannis_An34/status/1683549442287255552",
    "videos": null
  },
  "quotes": 607,
  "replies": 2752,
  "reposts": 14319,
  "tagged_users": null,
  "url": "https://x.com/FabrizioRomano/status/1683559267524136962",
  "user_posted": "FabrizioRomano",
  "videos": null,
  "views": 19844857
}
```

### Output Data Documentation

Here is the JSON fields documentation without including the sample values:

- **biography** (string): The biography or description associated with the user's profile.
- **bookmarks** (integer): The number of times the post has been bookmarked by users.
- **date\_posted** (string): The date and time when the post was created, in ISO 8601 format.
- **description** (string): The text content of the post.
- **external\_url** (string or null): A URL related to the post or user's profile. This can be an external link shared in the profile or post.
- **followers** (integer): The number of followers the user has.
- **following** (integer): The number of accounts the user is following.
- **hashtags** (array or null): An array of hashtags used in the post.
- **id** (string): A unique identifier for the post.
- **input** (object): Contains details about the input parameters used to retrieve the post.
  - **url** (string): The URL of the post.
- **is\_verified** (boolean): Indicates whether the user's account is verified on the platform.
- **likes** (integer): The number of likes the post has received.
- **name** (string): The name associated with the user's profile.
- **photos** (array or null): An array of URLs pointing to photos included in the post.
- **posts\_count** (integer): The total number of posts the user has made on the platform.
- **profile\_image\_link** (string): The URL to the user's profile image.
- **quoted\_post** (object or null): Details of the post that is being quoted or replied to, if applicable.
  - **date\_posted** (string or null): The date and time when the quoted post was created, in ISO 8601 format.
  - **description** (string): The text content of the quoted post.
  - **photos** (array or null): An array of URLs pointing to photos included in the quoted post.
  - **post\_id** (string): The unique identifier of the quoted post.
  - **profile\_id** (string): The unique identifier of the user who created the quoted post.
  - **profile\_name** (string): The name associated with the profile of the quoted post's creator.
  - **url** (string): The URL of the quoted post.
  - **videos** (array or null): An array of URLs pointing to videos included in the quoted post.
- **quotes** (integer): The number of times the post has been quoted.
- **replies** (integer): The number of replies to the post.
- **reposts** (integer): The number of times the post has been reposted.
- **tagged\_users** (array or null): An array of users tagged in the post.
- **url** (string): The URL of the post.
- **user\_posted** (string): The username of the person who posted the content.
- **videos** (array or null): An array of URLs pointing to videos included in the post.
- **views** (integer): The number of views the post has received.

# Actor input Schema

## `url` (type: `string`):

URL of the Twitter post to scrape

## Actor input object example

```json
{
  "url": "https://x.com/FabrizioRomano/status/1683559267524136962/"
}
```

# 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 = {
    "url": "https://x.com/FabrizioRomano/status/1683559267524136962/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("pratikdani/twitter-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 = { "url": "https://x.com/FabrizioRomano/status/1683559267524136962/" }

# Run the Actor and wait for it to finish
run = client.actor("pratikdani/twitter-posts-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 '{
  "url": "https://x.com/FabrizioRomano/status/1683559267524136962/"
}' |
apify call pratikdani/twitter-posts-scraper --silent --output-dataset

```

## MCP server setup

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