# X (Twitter) Following Scraper (`khadinakbar/x-following-scraper`) Actor

Scrape the accounts a Twitter/X user follows — username, bio, follower counts, location. Provider-backed, cookieless, no login required.

- **URL**: https://apify.com/khadinakbar/x-following-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, Lead generation, MCP servers
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event + usage

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#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

## X (Twitter) Following Scraper

Extract the public accounts a Twitter/X user follows — no API key, no login, no cookies required.

**Best for:** social graph research, brand monitoring, influencer discovery, competitor intelligence, and AI agent pipelines that need structured audience data.

***

### What you get

| Field | Example |
|---|---|
| `username` | `"nasa"` |
| `display_name` | `"NASA"` |
| `bio` | `"Explore the universe and discover our home planet."` |
| `follower_count` | `98500000` |
| `following_count` | `312` |
| `tweet_count` | `74200` |
| `verified` | `false` |
| `is_blue_verified` | `true` |
| `location` | `"Washington, DC"` |
| `website` | `"https://www.nasa.gov"` |
| `created_at` | `"Wed Jul 15 00:00:00 +0000 2009"` |
| `profile_image_url` | `"https://pbs.twimg.com/profile_images/…"` |
| `user_id` | `"11348282"` |
| `source_username` | `"natgeo"` |
| `scraped_at` | `"2026-08-19T12:34:56.789Z"` |

***

### Usage

#### Input — minimal

```json
{
  "usernames": ["natgeo"],
  "maxFollowingPerUser": 200
}
```

#### Input — multiple handles with global cap

```json
{
  "usernames": ["natgeo", "apify"],
  "maxFollowingPerUser": 500,
  "maxResults": 1000
}
```

#### API (via Apify)

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/khadinakbar~x-following-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"usernames":["natgeo"],"maxFollowingPerUser":100}'
```

***

### How it works

1. **SociaVault primary** — provider-backed route resolves user IDs and paginates the following list server-side with no login or cookies.
2. **Browser fallback** — if SociaVault is unavailable, a Playwright browser intercepts X's private GraphQL API. This path needs `authToken` + `csrfToken` from a logged-in session (store as secret env vars).
3. Proxy: Apify Residential US by default — reliably bypasses X's rate-limits.

***

### Pricing

**Pay per event + platform usage**

| Event | Price |
|---|---|
| Actor start | $0.00005 |
| `following-found` (per account) | $0.005 |

Typical cost: **$1.00 per 200 following accounts** plus ~$0.01–0.05 platform usage.

***

### Limitations

- **Private accounts** return zero rows (`VALID_EMPTY`) — X does not expose following lists for private profiles without login.
- Following counts above ~5,000 may require longer runtimes; use `maxFollowingPerUser` to cap.
- X may throttle or block unauthenticated requests. The actor retries automatically; persistent blocks are reported as `UPSTREAM_FAILED`.
- This actor returns who a user **follows**, not who follows them. For followers use `twitter-profile-followers-scraper`.

***

### Related actors

- [`twitter-profile-followers-scraper`](https://apify.com/khadinakbar/twitter-profile-followers-scraper) — scrape followers of an X account
- [`x-tweet-scraper`](https://apify.com/khadinakbar/x-tweet-scraper) — scrape tweets from a profile or search query
- [`twitter-profile-followers-scraper`](https://apify.com/khadinakbar/twitter-profile-followers-scraper) — profiles, followers, and following in one run

***

### Legal

This actor scrapes only publicly accessible data visible without login. Use responsibly and in compliance with X's Terms of Service and applicable data protection laws. The developer is not responsible for misuse.

# Actor input Schema

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

One or more Twitter/X handles to scrape the following list for. Accepts bare handles (e.g. 'natgeo') or full profile URLs (https://x.com/natgeo). Each handle produces one batch of following records. Defaults to 'natgeo' when nothing is provided. Not a tweet search — for tweets use x-tweet-scraper.

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

Alternatively supply full x.com profile URLs (e.g. https://x.com/natgeo). The username is parsed from the path. Use 'usernames' for simple handle lists. Not required when 'usernames' is set.

## `maxFollowingPerUser` (type: `integer`):

Maximum number of following accounts to return per input handle. Pagination stops when this limit is reached. Defaults to 200. Set to 0 for unlimited (may be slow for large lists).

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

Hard cap on total rows across all input handles. 0 means no global cap. Applies on top of maxFollowingPerUser. Useful for cost control in agent pipelines.

## `authToken` (type: `string`):

The auth\_token cookie value from a logged-in X session. Only needed when SociaVault is unavailable. Do not store in plain input — use the TWITTER\_AUTH\_TOKEN secret env var instead. Not your password or API key.

## `csrfToken` (type: `string`):

The ct0 CSRF token cookie from a logged-in X session. Pair with authToken for the browser fallback path. Use the TWITTER\_CSRF\_TOKEN secret env var to avoid exposing this in logs.

## `proxyConfiguration` (type: `object`):

Proxy settings passed to Apify's proxy service. Defaults to Apify Residential US which reliably bypasses X rate-limits. Not required to change for most use cases.

## Actor input object example

```json
{
  "usernames": [
    "natgeo",
    "apify"
  ],
  "startUrls": [
    {
      "url": "https://x.com/natgeo"
    }
  ],
  "maxFollowingPerUser": 200,
  "maxResults": 0,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

No description

## `outputSummary` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# 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 = {
    "usernames": [
        "natgeo"
    ],
    "maxFollowingPerUser": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/x-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 = {
    "usernames": ["natgeo"],
    "maxFollowingPerUser": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/x-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 '{
  "usernames": [
    "natgeo"
  ],
  "maxFollowingPerUser": 200
}' |
apify call khadinakbar/x-following-scraper --silent --output-dataset

```

## MCP server setup

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