Get the account ID

Follower routes use the numeric X user ID. Resolve the username once and save its ID.

cURL
curl "https://twitterxapi.com/api/v1/users/marclou?level=moderate" \
  -H "Authorization: Bearer $TWITTERXAPI_KEY"
Response saved from a live API call
{
  "id": "2311987360",
  "username": "marclou",
  "followersCount": 382499,
  "followingCount": 1246,
  "statusesCount": 36756,
  "verified": false
}

Fetch the first follower page

The response contains an items array plus pagination.next_cursor and pagination.has_more.

cURL
curl "https://twitterxapi.com/api/v1/users/by-id/2311987360/followers?level=moderate" \
  -H "Authorization: Bearer $TWITTERXAPI_KEY"
Response shape
{
  "items": ["..."],
  "count": 20,
  "pagination": {
    "next_cursor": "DAABCgAB...",
    "has_more": true
  }
}

Download every follower with Python

This loop writes newline delimited JSON as each page arrives. Memory use stays flat even for large accounts.

download_followers.py
import json, os, requests

base = "https://twitterxapi.com/api/v1"
headers = {"Authorization": f"Bearer {os.environ['TWITTERXAPI_KEY']}"}
profile = requests.get(f"{base}/users/marclou", headers=headers).json()
cursor = None
with open("followers.ndjson", "w") as output:
    while True:
        params = {"level": "moderate"}
        if cursor: params["cursor"] = cursor
        r = requests.get(f"{base}/users/by-id/{profile['id']}/followers", headers=headers, params=params, timeout=60)
        r.raise_for_status()
        page = r.json()
        for follower in page["items"]:
            output.write(json.dumps(follower) + "\n")
        cursor = page["pagination"]["next_cursor"]
        if not page["pagination"]["has_more"] or not cursor: break

Save CSV without losing the source data

Keep NDJSON as the master export and convert selected fields to CSV afterwards. Save the last cursor after every page so a stopped run can resume.

Questions

Can I download followers from a public X account?

Yes. Resolve the account ID and continue through follower pages until has_more is false.

Can I export Twitter followers to CSV?

Yes. Download NDJSON first, then select the columns you want for CSV.

Does this work for private accounts?

No. The API does not bypass private account controls.