# Twitter/X User Scraper: Metadata, Followers, Followings & More! (`scrape.badger/twitter-user-scraper`) Actor

ScrapeBadger's Twitter/X User Profile Scraper extracts public user data: IDs, profiles, followers, followings, & latest tweets. Perfect for market research, influencer ID, and building datasets. It's cost-effective, easy to use, and requires no API key. Get powerful user insights today!

- **URL**: https://apify.com/scrape.badger/twitter-user-scraper.md
- **Developed by:** [Scrape Badger](https://apify.com/scrape.badger) (community)
- **Categories:** Social media
- **Stats:** 426 total users, 49 monthly users, 99.2% runs succeeded, 14 bookmarks
- **User rating**: 4.94 out of 5 stars

## Pricing

$0.15 / 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

### ScrapeBadger: The Ultimate Twitter/X User Profile Scraper - Get Twitter User ID, Followers, and More!
[![Scrapebadger Twitter Scraper](https://raw.githubusercontent.com/ScrapeBadger/twitter-scraper/refs/heads/main/scrapebadger.png)](https://scrapebadger.com)

ScrapeBadger provides powerful data extraction capabilities to scrape Twitter/X user profiles, offering an incredibly affordable solution for comprehensive user data collection. Dive deep into public Twitter profiles, from fetching specific user details by <b>Twitter user ID</b> or username to extracting followers, followings, and even their latest tweets. All this starts at just <b>$0.20 per 1,000 results.</b>

Unleash the potential of public Twitter (now X) user data with ScrapeBadger's Twitter profiles scraper. Whether you're a market researcher, a social media analyst, a developer, or simply aiming to get Twitter user IDs and associated profile information, our tool provides a streamlined and cost-effective way to collect valuable insights. Gain reliable access to structured user information without the complexities of direct APIs, ideal for competitor analysis, influencer identification, audience segmentation, and more.

#### Key Features

* **Effortless User Data Retrieval:** Designed for **ease of use**, ScrapeBadger allows you to **select a Mode and provide its corresponding identifier** (e.g., User ID for "Get User by ID", username for "Get User by Username", search query for "Search Users").
* **Comprehensive User Profile Acquisition:**
    * **Get Twitter user ID** and detailed profile information for any public user by their ID or username. Access data points like name, screen name, profile image, bio, location, follower/following counts, and more.
    * **Get User About** information including account location, username history, and verification details.
    * Efficiently **scrape Twitter profile** data to build rich datasets for analysis.
* **Network Analysis & Engagement:**
    * Extract lists of **followers** and **followings** for any public user.
    * Get **verified followers** and **followers you know** (mutual connections).
    * Retrieve **latest followers** and **latest following** for recent network changes.
    * Access user's **highlighted tweets** and **subscriptions** (premium content).
* **Targeted User Search:** Perform powerful searches to discover Twitter/X users by keywords.
* **Flexible and Structured Output:** Data is delivered in Apify's standard Dataset, ready for export in CSV, JSON, etc.
* **Enterprise-Grade Reliability:** Built on the robust Apify platform for consistent results.
* **Cost-Effective Solution:** Just **$0.20 per 1,000 results**.

#### Great For

* **Social Media Marketing:** Identify influencers, analyze audience demographics, and track competitor followers.
* **Market Research:** Build datasets of users interested in specific topics, products, or services.
* **Academic & Research:** Gather data for social network analysis, demographic studies, and behavioral patterns.
* **Lead Generation:** Discover potential leads or connections based on their Twitter activity and connections.
* **Cybersecurity & OSINT:** Investigate public profiles for relevant information.
* **Developers & Data Scientists:** Integrate structured user data into your applications and analytical models.

#### How to Use - Mode-Specific Input Parameters

| Mode | Description | Key Input Parameter | JSON Parameter | Optional |
|:-----|:------------|:--------------------|:---------------|:---------|
| Get User by ID | Retrieve profile details using unique User ID | **User ID** | `user_id` | - |
| Get User by Username | Obtain profile information using username | **Username** | `username` | - |
| Get User About | Get extended about info (location, username history, verification) | **Username** | `username` | - |
| Get User Followers | Extract all users who follow a specified username | **Username** | `username` | `max_results` |
| Get User Followings | Retrieve all users that a username follows | **Username** | `username` | `max_results` |
| Get User Latest Tweets | Fetch recent tweets posted by a username | **Username** | `username` | `max_results` |
| Get User Highlights | Get a user's highlighted/pinned tweets | **User ID** | `user_id` | `max_results` |
| Get User Subscriptions | Get premium accounts a user subscribes to | **User ID** | `user_id` | `max_results` |
| Get Verified Followers | Extract only verified followers of a user | **User ID** | `user_id` | `max_results` |
| Get Followers You Know | Get mutual followers (followers you also follow) | **User ID** | `user_id` | `max_results` |
| Get Latest Followers | Get most recent followers of a user | **Username** | `username` | `max_results` |
| Get Latest Following | Get accounts a user most recently followed | **Username** | `username` | `max_results` |
| Search Users | Search for users by keywords | **Search Query** | `query` | `max_results` |

#### Request and Response Examples

##### 1. Get User by ID

**Request:**
```json
{
  "mode": "Get User by ID",
  "user_id": "183543469142"
}
````

##### 2. Get User by Username

**Request:**

```json
{
  "mode": "Get User by Username",
  "username": "elonmusk"
}
```

##### 3. Get User About

**Request:**

```json
{
  "mode": "Get User About",
  "username": "elonmusk"
}
```

**Response includes:**

- Account location/region
- Username change history
- Verification status and type
- Extended profile metadata

##### 4. Get User Followers

**Request:**

```json
{
  "mode": "Get User Followers",
  "username": "elonmusk",
  "max_results": 1000
}
```

##### 5. Get User Followings

**Request:**

```json
{
  "mode": "Get User Followings",
  "username": "elonmusk",
  "max_results": 1000
}
```

##### 6. Get User Latest Tweets

**Request:**

```json
{
  "mode": "Get User Latest Tweets",
  "username": "elonmusk",
  "max_results": 100
}
```

##### 7. Get User Highlights

**Request:**

```json
{
  "mode": "Get User Highlights",
  "user_id": "44196397",
  "max_results": 50
}
```

##### 8. Get User Subscriptions

**Request:**

```json
{
  "mode": "Get User Subscriptions",
  "user_id": "44196397",
  "max_results": 100
}
```

##### 9. Get Verified Followers

**Request:**

```json
{
  "mode": "Get Verified Followers",
  "user_id": "44196397",
  "max_results": 500
}
```

##### 10. Get Followers You Know

**Request:**

```json
{
  "mode": "Get Followers You Know",
  "user_id": "44196397",
  "max_results": 100
}
```

##### 11. Get Latest Followers

**Request:**

```json
{
  "mode": "Get Latest Followers",
  "username": "elonmusk",
  "max_results": 200
}
```

##### 12. Get Latest Following

**Request:**

```json
{
  "mode": "Get Latest Following",
  "username": "elonmusk",
  "max_results": 200
}
```

##### 13. Search Users

**Request:**

```json
{
  "mode": "Search Users",
  "query": "data scientist",
  "max_results": 100
}
```

#### Output Fields

User profile objects include:

- **Core:** id, username, name, description, location, url
- **Metrics:** followers\_count, following\_count, tweet\_count, listed\_count, favourites\_count, media\_count
- **Profile:** profile\_image\_url, profile\_banner\_url
- **Verification:** verified, verified\_type, is\_blue\_verified
- **Account:** created\_at, protected, possibly\_sensitive
- **Relationships:** followed\_by, following, blocking, muting, can\_dm

**Important Note:** To prevent API abuse and ensure fair resource allocation, you will be charged for requests that return an empty results set.

#### Why Choose ScrapeBadger?

- **Highly Targeted User Data:** Precisely extract the Twitter/X user information you need.
- **Efficient and Reliable:** Built for speed and stability on the Apify platform.
- **Unbeatable Value:** Just $0.20 per 1,000 results.
- **User-Friendly:** Easy to configure regardless of technical expertise.
- **Seamless Integration:** Output data readily available for analysis.

#### About ScrapeBadger

This actor is powered by [ScrapeBadger](https://scrapebadger.com) - a reliable Twitter/X data extraction service.

- **Official Website:** [scrapebadger.com](https://scrapebadger.com)
- **Faster Support:** Get priority support directly through the ScrapeBadger website
- **SDK & API Access:** Want to use ScrapeBadger outside of Apify? The Python SDK and REST API are available for direct integration into your own applications

# Actor input Schema

## `mode` (type: `string`):

Select the type of user data to scrape. Each mode requires different input parameters.

## `username` (type: `string`):

Twitter username without the @ symbol. Example: for https://x.com/<b>elonmusk</b>, enter <b>elonmusk</b>. Required for username-based modes.

## `user_id` (type: `string`):

The numeric Twitter User ID. You can find this using 'Get User by Username' mode first. Example: <b>15347622</b>. Required for ID-based modes.

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

Keywords to search for users. Searches usernames, display names, and bios. Example: <b>data scientist</b> or <b>crypto trader</b>. Required for 'Search Users' mode.

## `max_results` (type: `integer`):

Maximum number of items to return. Higher values increase run time and cost. Default: 1000.

## Actor input object example

```json
{
  "mode": "Get User by ID",
  "username": "james",
  "user_id": "15347622",
  "query": "intern",
  "max_results": 1000
}
```

# Actor output Schema

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

All scraped data including user profiles, tweets, and status indicators stored 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 = {
    "username": "james",
    "user_id": "15347622",
    "query": "intern"
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrape.badger/twitter-user-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 = {
    "username": "james",
    "user_id": "15347622",
    "query": "intern",
}

# Run the Actor and wait for it to finish
run = client.actor("scrape.badger/twitter-user-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 '{
  "username": "james",
  "user_id": "15347622",
  "query": "intern"
}' |
apify call scrape.badger/twitter-user-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Twitter/X User Scraper: Metadata, Followers, Followings & More!",
        "description": "ScrapeBadger's Twitter/X User Profile Scraper extracts public user data: IDs, profiles, followers, followings, & latest tweets. Perfect for market research, influencer ID, and building datasets. It's cost-effective, easy to use, and requires no API key. Get powerful user insights today!",
        "version": "1.3",
        "x-build-id": "X2MbEkYaaxDaJgOxF"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrape.badger~twitter-user-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrape.badger-twitter-user-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/scrape.badger~twitter-user-scraper/runs": {
            "post": {
                "operationId": "runs-sync-scrape.badger-twitter-user-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/scrape.badger~twitter-user-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-scrape.badger-twitter-user-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": [
                    "mode"
                ],
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "Get User by ID",
                            "Get User by Username",
                            "Get User About",
                            "Get User Followers",
                            "Get User Followings",
                            "Get User Latest Tweets",
                            "Get User Highlights",
                            "Get User Subscriptions",
                            "Get Verified Followers",
                            "Get Followers You Know",
                            "Get Latest Followers",
                            "Get Latest Following",
                            "Search Users"
                        ],
                        "type": "string",
                        "description": "Select the type of user data to scrape. Each mode requires different input parameters.",
                        "default": "Get User by ID"
                    },
                    "username": {
                        "title": "Username",
                        "type": "string",
                        "description": "Twitter username without the @ symbol. Example: for https://x.com/<b>elonmusk</b>, enter <b>elonmusk</b>. Required for username-based modes."
                    },
                    "user_id": {
                        "title": "User ID",
                        "type": "string",
                        "description": "The numeric Twitter User ID. You can find this using 'Get User by Username' mode first. Example: <b>15347622</b>. Required for ID-based modes."
                    },
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Keywords to search for users. Searches usernames, display names, and bios. Example: <b>data scientist</b> or <b>crypto trader</b>. Required for 'Search Users' mode."
                    },
                    "max_results": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Maximum number of items to return. Higher values increase run time and cost. Default: 1000.",
                        "default": 1000
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
