# Twitter Profile Scraper (`scrapeai/twitter-profile-scraper`) Actor

Scrapes public Twitter/X profiles, including usernames, bios, follower counts, verification status, location, profile images, and account statistics.

- **URL**: https://apify.com/scrapeai/twitter-profile-scraper.md
- **Developed by:** [ScrapeAI](https://apify.com/scrapeai) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 83.3% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.49 / 1,000 results

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/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 Profile Scraper

Returns X (Twitter) profiles: bio, follower counts, verification, location, images (with a token) or just name and handle (without).

### Where the data comes from

X does not allow automated access to its pages: the robots.txt of x.com, syndication.twitter.com and publish.twitter.com disallows it. This Actor therefore **never requests x.com**. It has two sources:

#### 1. Official X API v2 with your own bearer token (full data)

Add your app-only bearer token (create an app at developer.x.com) in the field **X API bearer token**. The Actor then calls only `api.x.com`: `GET /2/users/by/username/:username`. Records contain the data the API returns (counts, dates, media, authors, followers ...). The token is stored encrypted, sent only to api.x.com and never written to the dataset or the log. Which endpoints you can use, and how many requests you get, depends on your X API plan; the Actor reports X's error (401, 403, 429) in the run status.

#### 2. Without a token: public Google results

Name and handle of each account, read from the title Google shows for its profile page or posts. Nothing else is shown there: no bio, no follower counts, no location, no images.

The Google results are read through Apify's `GOOGLE_SERP` proxy group: one Google Images page per search, never repeated to get a different layout, no cookies, no browser User-Agent. x.com itself is not contacted. The creation time of a post is decoded from its post id (X ids contain the time); everything else is exactly what Google shows.

### Input

| Field | Type | Description |
| --- | --- | --- |
| `profileUrls` | array | X profile URLs, for example https://x.com/apify. |
| `usernames` | array | X handles without the @, for example apify. |
| `xBearerToken` | string (secret) | Your own app-only bearer token for the official X API v2 (create an app at developer.x.com). With a token the Actor returns full data (counts, dates, media, followers) from api.x.com; the token is stored encrypted and sent only to api.x.com. Leave it empty to read public Google results instead (limited data, see the README). |
| `dataSource` | string | Automatic: the X API when a bearer token is given, otherwise public Google results. X API: always the X API (needs a token). Google results: always Google results, even when a token is given. |
| `maxItems` | integer | Maximum number of records to write to the dataset. |
| `maxRequests` | integer | Maximum number of requests per run: X API calls, or Google result pages (one per search term or account). |
| `includeRawData` | boolean | X API only: add the raw API object to each record. Keep disabled unless needed. |
| `debugLog` | boolean | Enable diagnostic logs without logging credentials. |

Example input (the same as the default input of the Actor):

```json
{
  "profileUrls": [
    "https://x.com/X"
  ],
  "usernames": [
    "X"
  ],
  "dataSource": "auto",
  "maxItems": 10,
  "maxRequests": 5,
  "includeRawData": false,
  "debugLog": false
}
```

### Output

Record read from Google results (`dataOrigin: google-serp-images`):

```json
{
  "platform": "twitter",
  "actorMode": "profile",
  "recordType": "profile",
  "username": "apify",
  "displayName": "Apify",
  "profileUrl": "https://x.com/apify",
  "handleShownInProfileTitle": true,
  "retrievalMethod": "google-serp-images",
  "dataOrigin": "google-serp-images",
  "serpQuery": "site:x.com/apify",
  "scrapedAt": "2026-11-14T12:00:00.000Z"
}
```

Records read from the X API (`retrievalMethod: x-api-v2`) carry the full API data: text, `createdAt`, counts (`likeCount`, `replyCount`, `retweetCount`, `viewCount` ...), author, media, links, mentions; profiles carry bio, location, follower and following counts and verification.

### Limits

- Without a token the Actor returns no counts, no follower numbers and no complete timelines: Google lists only part of what exists on X. Fields that Google does not show are left out, never filled in.
- A run that finds nothing fails with a message instead of returning an empty dataset.
- Run `npm test` in the Actor folder to execute the unit tests (they use saved results and a fake X API; no network).

# Changelog

This Actor's version history is a separate document: https://apify.com/scrapeai/twitter-profile-scraper/changelog.md

# Actor input Schema

## `profileUrls` (type: `array`):

X profile URLs, for example https://x.com/apify.

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

X handles without the @, for example apify.

## `xBearerToken` (type: `string`):

Your own app-only bearer token for the official X API v2 (create an app at developer.x.com). With a token the Actor returns full data (counts, dates, media, followers) from api.x.com; the token is stored encrypted and sent only to api.x.com. Leave it empty to read public Google results instead (limited data, see the README).

## `dataSource` (type: `string`):

Automatic: the X API when a bearer token is given, otherwise public Google results. X API: always the X API (needs a token). Google results: always Google results, even when a token is given.

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

Maximum number of records to write to the dataset.

## `maxRequests` (type: `integer`):

Maximum number of requests per run: X API calls, or Google result pages (one per search term or account).

## `includeRawData` (type: `boolean`):

X API only: add the raw API object to each record. Keep disabled unless needed.

## `debugLog` (type: `boolean`):

Enable diagnostic logs without logging credentials.

## Actor input object example

```json
{
  "profileUrls": [
    "https://x.com/X"
  ],
  "usernames": [
    "X"
  ],
  "dataSource": "auto",
  "maxItems": 10,
  "maxRequests": 5,
  "includeRawData": false,
  "debugLog": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing live profile records.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeai/twitter-profile-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("scrapeai/twitter-profile-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 '{}' |
apify call scrapeai/twitter-profile-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapeai/twitter-profile-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/5Re7jCKI6iO421M9g/builds/yfBdUAvjMOQvJOThO/openapi.json
