How to Get X Followers with TwexAPI
Follower data is useful only when the collection method is clear. A one-page "latest followers" pull is good for a quick check. A paginated export is better when you need a repeatable dataset.
This guide shows both approaches with TwexAPI, using elonmusk as an example screen name. Replace it with the account you are allowed to analyze.
Choose the Right Endpoint
| Task | Endpoint | When to use it |
|---|---|---|
| Fetch recent followers | GET /twitter/latest-followers/{screen_name} | Quick sampling or monitoring recent follower changes. |
| Fetch followers by page | POST /twitter/followers/page | Cursor-based export where each page can be saved and deduplicated. |
| Fetch a fixed count | GET /twitter/followers/{screen_name}/{count} | Small one-off jobs when you already know the count you need. |
Use paginated export for anything you plan to compare, enrich, or report on. It gives you a cleaner audit trail than a single large response.
Get Latest Followers
curl --request GET \
--url https://api.twexapi.io/twitter/latest-followers/elonmusk \
--header 'Authorization: Bearer <token>'Use this when you need a quick look at recent followers. Save the run time with the response, because "latest" is time-sensitive.
Page Through Followers
POST /twitter/followers/page accepts a screen_name and an optional next_cursor. For the first request, omit next_cursor. When the response includes another cursor, pass it into the next request.
curl --request POST \
--url https://api.twexapi.io/twitter/followers/page \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"screen_name": "elonmusk"
}'{
"code": 200,
"msg": "success",
"data": [],
"has_next_page": true,
"next_cursor": "1234567890"
}Python Collector
The collector below saves a bounded number of pages and normalizes the follower fields you are most likely to use in a review table.
1import os
2from typing import Any
3
4import requests
5
6TOKEN = os.environ["TWEXAPI_BEARER_TOKEN"]
7BASE_URL = "https://api.twexapi.io"
8
9def headers() -> dict[str, str]:
10 return {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}
11
12def get_latest_followers(screen_name: str) -> list[dict[str, Any]]:
13 response = requests.get(
14 f"{BASE_URL}/twitter/latest-followers/{screen_name}",
15 headers=headers(),
16 timeout=30,
17 )
18 response.raise_for_status()
19 return response.json().get("data", [])
20
21def get_followers_page(
22 screen_name: str,
23 *,
24 next_cursor: str | None = None,
25) -> dict[str, Any]:
26 payload: dict[str, Any] = {"screen_name": screen_name}
27 if next_cursor:
28 payload["next_cursor"] = next_cursor
29
30 response = requests.post(
31 f"{BASE_URL}/twitter/followers/page",
32 headers=headers(),
33 json=payload,
34 timeout=30,
35 )
36 response.raise_for_status()
37 return response.json()
38
39def normalize_follower(user: dict[str, Any]) -> dict[str, Any]:
40 return {
41 "user_id": user.get("user_id") or user.get("userId") or user.get("id"),
42 "screen_name": user.get("screen_name") or user.get("username"),
43 "name": user.get("name"),
44 "description": user.get("description") or "",
45 "followers_count": user.get("followers_count") or user.get("followersCount") or 0,
46 "verified": bool(user.get("verified")),
47 "protected": bool(user.get("protected")),
48 "created_at": user.get("created_at_datetime") or user.get("createdAtDatetime") or user.get("createdAt"),
49 }
50
51def collect_followers(screen_name: str, max_pages: int = 3) -> list[dict[str, Any]]:
52 rows: list[dict[str, Any]] = []
53 seen_ids: set[str] = set()
54 cursor = None
55
56 for _ in range(max_pages):
57 page = get_followers_page(screen_name, next_cursor=cursor)
58 for user in page.get("data", []):
59 row = normalize_follower(user)
60 user_id = str(row.get("user_id") or "")
61 if user_id and user_id in seen_ids:
62 continue
63 if user_id:
64 seen_ids.add(user_id)
65 rows.append(row)
66
67 cursor = page.get("next_cursor")
68 if not page.get("has_next_page") or not cursor:
69 break
70
71 return rows
72
73if __name__ == "__main__":
74 followers = collect_followers("elonmusk", max_pages=2)
75 print(len(followers))Data Hygiene
- Record
screen_name, run time, endpoint, and cursor for every page. - Deduplicate by stable user id when it is available.
- Keep protected-account flags and empty bios as data, not errors.
- Do not use follower count alone to rank quality or intent.
- Avoid using follower exports for unsolicited outreach without consent and compliance review.
Wrap-up
Use GET /twitter/latest-followers/{screen_name} for quick checks and POST /twitter/followers/page for repeatable exports.
The cleaner workflow is simple: page the data, save the cursors, normalize profile fields, deduplicate by user id, and document why the follower list was collected.