# Twitter (X) User Profile Scraper by Handle (`smart_albatross/x-profile-scraper`) Actor

Get public X/Twitter profiles by username or profile URL: bios, followers, following, verification, images, creation dates and explicit DM permission data. Export JSON, CSV or Excel.

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

## Pricing

from $0.20 / 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/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) User Profile Scraper by Handle

Get public X/Twitter profiles by username or profile URL: bios, followers, following, verification, images, creation dates and explicit DM permission data. Export JSON, CSV or Excel.

### What this Actor collects

Look up public profiles by handle or profile URL. Numeric user IDs are not supported. One profile is returned per accessible unique account. Suspended or inaccessible handles are recorded as failed sources in COVERAGE.

Handles are looked up in batches of up to 100 using pure HTTP. Results are matched by handle, not response order. If X omits a handle, the Actor checks it individually before reporting it unavailable. This also handles aliases or renamed accounts without guessing which input owns a result.

If the bulk query becomes unavailable or its shared POST budget is exhausted, collection switches to the existing single-handle GET lookup for the rest of that run, subject to its separate account budget. This is not unlimited capacity: the Actors share the same X account pool. Coordinator outages remain fail-closed; the Actor does not bypass the shared ledger.

### Quick start

Enter inputs, start with a small maxItems, and run. No customer X cookies are required. Export the default dataset as JSON, CSV, Excel or JSONL, or use the Apify API.

```json
{
  "twitterHandles": [
    "NASA",
    "the_hindu"
  ],
  "maxItems": 100
}
```

### Limits and deduplication

maxItems is the total unique output ceiling, not a per-source allowance. maxItemsPerSource caps each input and defaults to maxItems. maxDurationSeconds defaults to 300 and cannot exceed 600. Account rate limits, spending limits and X visibility may yield fewer results. Startup has bounded retries; very short deadlines may elapse during initialization.

IDs are strings. No duplicate IDs are emitted within a run; migration recovery reconciles existing writes. If several inputs discover the same record, the **first source** gets attribution. This is a unique-profile/result export, not an exhaustive relationship-edge export.

### Output schema

Rows are flat user profiles with id, userName, name, url, description, followers, following, verification, images, createdAt, canDm and additional normalized fields. Every row includes sourceInput, sourceType and searchTerm. searchTerm is the query for user search, otherwise an empty string.

canDm reads dm_permissions.can_dm or legacy.can_dm: true/false when reported, null when unknown. Permission can depend on the authenticated X account; it is not a global guarantee that anyone may DM that profile.

The Output tab links to results and COVERAGE. COVERAGE lists source/strategy pages, limits, failures, repeated cursors and the exact stop reason. Dataset and output schemas are included for Store publishing.

For profiles, COVERAGE also includes `profileLookupRequests`: logical lookup calls made by the runner, excluding initialization, internal retries and query-ID fallback wire attempts. One bulk call is attributed once, to its first source. Per-source `pages` can include the same shared batch response; do not sum them to estimate HTTP calls. `profileFallback` identifies omitted-profile or bulk-unavailable single lookups. Dataset fields and customer input remain unchanged.

Older per-handle checkpoints can resume through batching. Already written profiles are reconciled from the dataset and are not requested or billed again. Only successfully written rows advance output counters; spending-limit truncation leaves unwritten sources pending.

### Coverage and responsible use

X may withhold protected, deleted, blocked, suspended or unindexed content, or shorten lists despite larger public counters. An empty result is **not a completeness guarantee**. This Actor does not bypass access controls. Follow applicable terms and privacy obligations.

### API

After deployment, POST JSON input to https://api.apify.com/v2/acts/<owner>~x-profile-scraper/runs using an Authorization bearer token. Read items from the run's default dataset. Never put tokens in public URLs.

### Operator setup

Not yet published; no price or Store publication is configured. Each new Actor requires secret X_ACCOUNTS and proxy environment configuration. Credentials never belong in input forms, source, datasets or logs. Arbitrary JavaScript mapping is not supported.

Prepare a clean build directory:

```sh
node scripts/prepare-actor.mjs profiles
```

Build from .artifacts/actors/profiles. Staging never deploys or publishes. Memory is fixed at 1024 MB. Pure HTTP with compressed responses and account-aware rate limits; no browser or third-party data API.

# Actor input Schema

## `twitterHandles` (type: `array`):

Usernames such as NASA or @NASA, or profile URLs such as https://x.com/NASA. Do not enter tweet URLs or numeric IDs here.

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

Run-wide ceiling shared across all inputs. Unique IDs only; spending limits or the runtime deadline may stop the run earlier.

## `maxItemsPerSource` (type: `integer`):

Optional per-handle, per-tweet or per-query cap shared by all strategies for that input. Defaults to maxItems. Duplicates attributed to earlier sources do not count again.

## `maxDurationSeconds` (type: `integer`):

Includes initialization and collection. Defaults to five minutes; very short deadlines may elapse during bounded startup. See COVERAGE for incomplete sources.

## Actor input object example

```json
{
  "twitterHandles": [
    "NASA"
  ],
  "maxItems": 1000,
  "maxDurationSeconds": 300
}
```

# Actor output Schema

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

Stable normalized records with source attribution. Export through the dataset UI or API.

## `coverage` (type: `string`):

Stop reason, per-strategy page counts and failures. Output is not a completeness guarantee.

# 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 = {
    "twitterHandles": [
        "NASA"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("smart_albatross/x-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 = { "twitterHandles": ["NASA"] }

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

```

## MCP server setup

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