# Twitter X.com Followers & Following Scraper (`xtdata/twitter-x-followers-following-scraper`) Actor

Scrape followers and following lists of any public Twitter (X.com) account by username, user ID or profile URL. Get full profiles with follower counts, websites and emails from bios. Filter by followers, verified, email or website before you pay. No login needed.

- **URL**: https://apify.com/xtdata/twitter-x-followers-following-scraper.md
- **Developed by:** [xtdata](https://apify.com/xtdata) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 follower data

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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?

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 X.com Followers & Following Scraper

Scrape the followers and the following list of any public Twitter (X.com) account. Give usernames, user IDs or profile
URLs and get full profiles of the people in each list, with follower counts, websites and emails found in bios.

### Key Features

- **Followers and following:** choose `getFollowers` (on by default), `getFollowing`, or both. Every result has a `type`
  (`follower` or `following`) and `sourceUser`, the account whose list it came from.
- **Flexible input:** usernames (`elonmusk` or `@elonmusk`), numeric user IDs (`44196397`) and profile URLs
  (`https://x.com/apify`, `https://x.com/apify/followers`). Many accounts in one run.
- **Filters before you pay:** `minFollowers`, `maxFollowers`, `onlyVerified`, `onlyWithEmail`, `onlyWithWebsite`.
  Users that do not match are neither delivered nor charged. `maxScanned` limits how many profiles are checked per list
  (default: `maxItems` x 5).
- **Lead-friendly fields:** every user has `website` (the expanded profile link) and `emails` (addresses found in the bio).
- **Exact limits:** `maxItems` is exact per account and list, duplicates are removed, and the run respects your maximum
  cost. An interrupted run continues where it stopped, without duplicates.
- **Custom map function:** reshape each result with your own JavaScript, run in an isolated process.

### Use Cases

- **Audience analysis:** see who follows a brand, a creator or a competitor.
- **Lead generation:** collect followers who have an email or a website in their profile.
- **Influencer research:** find the accounts with the most followers inside an audience.
- **Network mapping:** build a social graph from followers and following lists.

### Quick Start Examples

**Followers of two accounts:**

```json
{
    "usernames": ["elonmusk", "nasa"],
    "maxItems": 100
}
```

**Followers with at least 1,000 followers and an email in the bio:**

```json
{
    "startUrls": ["https://x.com/apify"],
    "minFollowers": 1000,
    "onlyWithEmail": true,
    "maxItems": 100
}
```

**Following list only, by user ID:**

```json
{
    "userIds": ["44196397"],
    "getFollowers": false,
    "getFollowing": true,
    "maxItems": 50
}
```

**Both lists:**

```json
{
    "usernames": ["apify"],
    "getFollowers": true,
    "getFollowing": true,
    "maxItems": 200
}
```

### Input Parameters

| Field | Type | Description |
|---|---|---|
| `startUrls` | `string[]` | Profile URLs. Strings or `{ "url": ... }` objects. |
| `usernames` | `string[]` | Usernames, with or without `@`. |
| `userIds` | `string[]` | Numeric user IDs. |
| `getFollowers` | `boolean` | Scrape the followers of each account (default `true`). |
| `getFollowing` | `boolean` | Scrape the accounts each account follows (default `false`). |
| `maxItems` | `integer` | Max users per account and list (default `20`). |
| `minFollowers`, `maxFollowers` | `integer` | Follower count range. |
| `onlyVerified` | `boolean` | Verified or blue verified users only. |
| `onlyWithEmail` | `boolean` | Only users with an email in the bio. |
| `onlyWithWebsite` | `boolean` | Only users with a website. |
| `maxScanned` | `integer` | Max profiles checked per list when filters are on (default `maxItems` x 5). |
| `customMapFunction` | `string` | JavaScript function to transform each result. Not for filtering. |

The older names `shouldScrapeFollowers`, `shouldScrapeFollowings` and `twitterHandles` are still accepted.

### Pricing

Pay per event, with no start charge: `follower` for each delivered follower and `following` for each delivered followed
account. Only delivered results are charged, so users removed by filters are free.

### Output Example

```json
{
    "type": "follower",
    "id": "2990041791",
    "name": "Bakr FARIS",
    "username": "FarisBakr",
    "description": "Software engineer. Contact: hello@example.com",
    "followersCount": 7385,
    "followingCount": 4047,
    "tweetCount": 86295,
    "likeCount": 138056,
    "listedCount": 0,
    "mediaCount": 5619,
    "createdAt": "Wed Jan 21 15:34:59 +0000 2015",
    "location": "Casablanca, Grand Casablanca",
    "verified": false,
    "isBlueVerified": false,
    "profileImageUrl": "https://pbs.twimg.com/profile_images/1614598066509602816/BKSi0VBD_normal.jpg",
    "profileBannerUrl": "https://pbs.twimg.com/profile_banners/2990041791/1421944124",
    "profileUrl": "https://x.com/FarisBakr",
    "protected": false,
    "pinned_tweet_ids_str": ["755286242946904068"],
    "website": "https://example.com",
    "emails": ["hello@example.com"],
    "sourceUser": "elonmusk",
    "searchTerms": "elonmusk"
}
```

`sourceUser` (and its copy `searchTerms`) is the username or user ID you gave.

### Custom Map Function

`customMapFunction` is plain, synchronous JavaScript that runs in a separate process. It receives a copy of each item and returns the
object to save. If it returns nothing, an array or a promise, throws, or takes too long, the original item is saved.

- Available: all JavaScript built-ins (`JSON`, `Math`, `Date`, `RegExp`, `Intl`, `Map` and so on) and simple versions of
  `console` (prints nothing), `URL` (absolute URLs, read only), `structuredClone` (JSON values), `atob`, `btoa`,
  `crypto.randomUUID()` and `performance.now()`.
- Not available: `process`, `require`, the word `import`, `fetch`, timers, `Buffer`, `TextEncoder`, `TextDecoder`,
  `URLSearchParams`, `eval` and `new Function`.

### Ethical Use and Data Practices

Our actor operates without logging in to X.com. This means it does not implicitly accept any Terms of Service (ToS)
that require a login, as we only process data that is publicly displayed and accessible to everyone without
authentication.

We are fully committed to the principle of privacy by design and by default. All data collected explicitly excludes
sensitive personal information or non-public data.

Furthermore, our actor runs on Apify, an EU-based company, which means our operations are designed to be compliant with
relevant EU data protection regulations, including GDPR, where applicable. You can find more information about the
legality of web scraping on Apify's blog: https://blog.apify.com/is-web-scraping-legal/

### Troubleshooting

- Protected (private) accounts do not show their lists, so they return no data and are not charged.
- A list may end before `maxItems` when X shows fewer users than the account's follower count.
- With filters on, few results can mean the first `maxScanned` profiles did not match. Raise `maxScanned` or relax the filters.
- If every request fails, the run fails and nothing is charged. If only some fail, the run finishes with partial results
  and a message in the log.

### Guides

- [Turn any X (Twitter) audience into a lead list](https://scrapingenthusiast.github.io/apify/twitter-x-followers-following-scraper-lead-generation/):
  a no-code walkthrough with filter setups for competitor audiences, micro-influencers and following lists.
- [Scrape X followers and following lists from Node.js](https://novidevelop.github.io/apify/scrape-x-twitter-followers-nodejs/):
  `apify-client` code with filters, a cost cap, merging several accounts and CSV export.
- [Measuring X audience overlap from follower samples](https://scrapingnerd.github.io/apify/x-twitter-audience-overlap-follower-sampling/):
  sampling bias, overlap metrics, sizing `maxScanned` and the cost model.

### Get Started

Add a few usernames, choose followers, following or both, and run the Actor. Results are ready to download as JSON,
CSV or Excel, or to use through the Apify API.

#### **1. TikTok Actors**

|                                                                                                                                     |                                                                                                       |                                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [⚡ Fast TikTok API (No WM)](https://apify.com/novi/fast-tiktok-api?fpr=7hce1m)                                                      | [👤 Tiktok User Profile API](https://apify.com/novi/tiktok-user-info-api?fpr=7hce1m)                  | [🔍 Advanced Search TikTok](https://apify.com/novi/advanced-search-tiktok-api?fpr=7hce1m)  |
| [🔎 TikTok Search Scraper](https://apify.com/novi/tiktok-search-api?fpr=7hce1m)                                                     | [📈 Tiktok Trend API](https://apify.com/novi/tiktok-trend-api?fpr=7hce1m)                             | [💬 TikTok Comment API](https://apify.com/novi/tiktok-comment-api?fpr=7hce1m)              |
| [🎞️ TikTok Profile Videos API](https://apify.com/novi/tiktok-user-api?fpr=7hce1m)                                                  | [#️⃣ TikTok Hashtag API](https://apify.com/novi/tiktok-hashtag-api?fpr=7hce1m)                        | [🎵 TikTok Sound Music API](https://apify.com/novi/tiktok-sound-api?fpr=7hce1m)            |
| [👥 TikTok Followers API](https://apify.com/novi/tiktok-followers-api?fpr=7hce1m)                                                   | [🔢 Multiple Hashtags Scraper](https://apify.com/novi/multiple-tiktok-hashtag-scraper?fpr=7hce1m)     | [🏆 TikTok Scraper Ultimate](https://apify.com/novi/tiktok-scraper-ultimate?fpr=7hce1m)    |
| [🎶 TikTok Music Trend API](https://apify.com/novi/tiktok-music-trend-api?fpr=7hce1m)                                               | [🛍️ TikTok Shop Scraper](https://apify.com/novi/tiktok-shop-scraper?fpr=7hce1m)                      | [💰 TikTok Scraper (Pay per video)](https://apify.com/novi/fast-tiktok-scraper?fpr=7hce1m) |
| [📄 Fast TikTok API (Simple)](https://apify.com/novi/fast-tiktok-api-with-simple-result?fpr=7hce1m) | [🆔 TikTok User Profile Scraper](https://apify.com/xtdata/tiktok-user-information-scraper?fpr=7hce1m) | [📍 TikTok Location API](https://apify.com/novi/tiktok-location-api?fpr=7hce1m)            |
| [🤖 TikTok AI Video Scraper](https://apify.com/novi/tiktok-ai-video-scraper?fpr=7hce1m)                                             | [🗯️ TikTok Comment (Novi)](https://apify.com/novi/tiktok-comment-scraper?fpr=7hce1m)                 | [🏷️ TikTok Scraper (Fixed price)](https://apify.com/xtdata/tiktok-scraper?fpr=7hce1m)     |
| [🗣️ TikTok Comment + Replies](https://apify.com/xtdata/tiktok-comment-scraper?fpr=7hce1m)                                          |                                                                                                       |                                                                                            |

#### **2. X.com (Twitter) Actors**

|                                                                                       |                                                                                                           |                                                                                                           |
|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| [🐦 X.com Twitter API Scraper](https://apify.com/xtdata/twitter-x-scraper?fpr=7hce1m) | [🐦 X.com Twitter User Tweets Scraper](https://apify.com/xtdata/twitter-x-user-tweets-scraper?fpr=7hce1m) | [🐦 X.com Twitter User Info Scraper](https://apify.com/xtdata/twitter-x-user-info-scraper?fpr=7hce1m) |

#### **3. YouTube Actors**

|                                                                                       |  |  |
|---------------------------------------------------------------------------------------|--|--|
| [📜 YouTube Transcript API](https://apify.com/novi/youtube-transcript-api?fpr=7hce1m) |  |  |

# Changelog

This Actor's version history is a separate document: https://apify.com/xtdata/twitter-x-followers-following-scraper/changelog.md

# Actor input Schema

## `startUrls` (type: `array`):

Profile URLs, for example https://x.com/apify. URLs such as https://x.com/apify/followers or /following work too.

## `usernames` (type: `array`):

Twitter/X usernames, with or without @. You can combine them with user IDs and profile URLs.

## `userIds` (type: `array`):

Twitter/X numeric user IDs. You can combine them with usernames and profile URLs.

## `getFollowers` (type: `boolean`):

Scrape the accounts that follow each user.

## `getFollowing` (type: `boolean`):

Scrape the accounts each user follows.

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

Maximum number of followers (and of following) to deliver for each user.

## `minFollowers` (type: `integer`):

Only deliver users with at least this many followers.

## `maxFollowers` (type: `integer`):

Only deliver users with at most this many followers.

## `onlyVerified` (type: `boolean`):

Only deliver verified users (legacy verified or blue verified).

## `onlyWithEmail` (type: `boolean`):

Only deliver users who have an email address in their bio.

## `onlyWithWebsite` (type: `boolean`):

Only deliver users who have a website in their profile.

## `maxScanned` (type: `integer`):

When filters are on, the Actor stops a list after checking this many profiles, even if fewer than Max users matched. Default: Max users per list x 5.

## `customMapFunction` (type: `string`):

Function that takes each result object as argument and returns the object to save. It runs in an isolated process with plain JavaScript only (no modules, timers, Buffer or import). See the README for the available globals. It is not intended for filtering: if it returns nothing or fails, the original object is saved.

## Actor input object example

```json
{
  "startUrls": [
    "https://x.com/apify"
  ],
  "usernames": [
    "elonmusk"
  ],
  "getFollowers": true,
  "getFollowing": false,
  "maxItems": 100,
  "onlyVerified": false,
  "onlyWithEmail": false,
  "onlyWithWebsite": false,
  "customMapFunction": "(object) => { return {...object} }"
}
```

# Actor output Schema

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

Follower and following profiles in the default dataset. Every item has a type (follower or following), sourceUser (the user whose list it came from), website and emails.

# 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 = {
    "startUrls": [
        "https://x.com/apify"
    ],
    "usernames": [
        "elonmusk"
    ],
    "maxItems": 100,
    "customMapFunction": (object) => { return {...object} }
};

// Run the Actor and wait for it to finish
const run = await client.actor("xtdata/twitter-x-followers-following-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 = {
    "startUrls": ["https://x.com/apify"],
    "usernames": ["elonmusk"],
    "maxItems": 100,
    "customMapFunction": "(object) => { return {...object} }",
}

# Run the Actor and wait for it to finish
run = client.actor("xtdata/twitter-x-followers-following-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 '{
  "startUrls": [
    "https://x.com/apify"
  ],
  "usernames": [
    "elonmusk"
  ],
  "maxItems": 100,
  "customMapFunction": "(object) => { return {...object} }"
}' |
apify call xtdata/twitter-x-followers-following-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xtdata/twitter-x-followers-following-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/DayHVNlgyxYEbgZjj/builds/qGqBhjhHlXXlwK60f/openapi.json
