How to Collect Cerfia public social data via API

Author:TwexAPI Team
EN
Read in:
English
日本語中文
TwexAPI
public social data
User Timeline
Public Account Research
Python
Cerfia

Use TwexAPI to collect public profile metadata, timeline posts, and optional search results for the Cerfia public platform account in a structured, auditable workflow.

Quick Answer

Cerfia fact-checking workflows can pull claim-related posts with TwexAPI search operators, then enrich the dataset with reply threads and promotion flags. Store source URLs, retrieval times, raw JSON, and any 100-ID batch boundaries so every annotation remains auditable.

FAQ

Why use TwexAPI instead of the first-party developer API for this workflow?

For fact-check pipelines, TwexAPI provides Bearer-authenticated workflows documented at https://docs.twexapi.io. A typical post or profile read uses 5 Credits (about $0.05 per 1,000 under the published conversion), and qualifying paid plans publish 20+ QPS. New accounts receive 20,000 starting Credits. As of 2026-08-20, first-party developer API Post reads list at $5 per 1,000 resources and User reads at $10 per 1,000; official rate limits vary by endpoint and access level.

How much does this API workflow cost on TwexAPI?

A typical read uses about 5 Credits. Under the published conversion, 1,000 such reads use 5,000 Credits, or about $0.05; a 10,000-read job uses about 50,000 Credits. Actual costs vary by endpoint, so confirm the endpoint price and current plan at https://twexapi.io/pricing.

When you need data from a public X account, keep the workflow concrete: collect the profile snapshot, page through recent posts, and run topic-specific searches only when you need a filtered subset.

This guide uses CerfiaFR as the example screen name. If the account handle changes, replace the screen name before running the requests.

Collection Plan

Answer: Collection Plan means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

Use three TwexAPI endpoints depending on the data you need:

TaskEndpointWhen to use it
Get public account metadataGET /twitter/{screen_name}/aboutCapture profile fields before collecting posts.
Page through the account timelinePOST /twitter/{screen_name}/timeline/pageCollect recent posts with cursor pagination.
Search within public X resultsPOST /twitter/advanced_search/pageFilter by query, such as from:CerfiaFR climate, and paginate search results.

Store both the raw response and the normalized rows. The raw response gives you an audit trail if your parser changes later.

Get Account Metadata

Answer: Get Account Metadata means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

curl --request GET \
  --url https://api.twexapi.io/twitter/CerfiaFR/about \
  --header 'Authorization: Bearer <token>'

Keep this profile snapshot separate from the post table. It can include account identifiers, display fields, description text, and public counters returned by the API.

Page Through Timeline Posts

Answer: Page Through Timeline Posts means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

POST /twitter/{screen_name}/timeline/page accepts count and next_cursor. Use the first response's next_cursor for the next page while has_next_page is true.

curl --request POST \
  --url https://api.twexapi.io/twitter/CerfiaFR/timeline/page \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "count": 20
  }'

The response includes the current data page plus pagination fields.

{
  "code": 200,
  "msg": "success",
  "data": [],
  "has_next_page": true,
  "next_cursor": "DAAHCgAB...",
  "requested_count": 20,
  "effective_count": 20,
  "parsed_count": 20
}

Python Collector

Answer: Python Collector means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

This collector retrieves a bounded number of timeline pages and produces review-friendly rows.

1import os
2from typing import Any
3
4import requests
5
6TOKEN = os.environ["TWEXAPI_BEARER_TOKEN"]
7SCREEN_NAME = "CerfiaFR"
8BASE_URL = "https://api.twexapi.io"
9
10def headers() -> dict[str, str]:
11    return {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}
12
13def get_profile(screen_name: str) -> dict[str, Any] | None:
14    response = requests.get(
15        f"{BASE_URL}/twitter/{screen_name}/about",
16        headers=headers(),
17        timeout=30,
18    )
19    response.raise_for_status()
20    return response.json().get("data")
21
22def get_timeline_page(
23    screen_name: str,
24    *,
25    count: int = 20,
26    next_cursor: str | None = None,
27) -> dict[str, Any]:
28    payload: dict[str, Any] = {"count": count}
29    if next_cursor:
30        payload["next_cursor"] = next_cursor
31
32    response = requests.post(
33        f"{BASE_URL}/twitter/{screen_name}/timeline/page",
34        headers=headers(),
35        json=payload,
36        timeout=30,
37    )
38    response.raise_for_status()
39    return response.json()
40
41def normalize_post(post: dict[str, Any]) -> dict[str, Any]:
42    tweet_id = post.get("tweet_id") or post.get("id")
43    return {
44        "tweet_id": tweet_id,
45        "created_at": post.get("created_at_datetime") or post.get("created_at"),
46        "text": post.get("full_text") or post.get("text") or "",
47        "favorite_count": post.get("favorite_count") or 0,
48        "retweet_count": post.get("retweet_count") or 0,
49        "reply_count": post.get("reply_count") or 0,
50        "quote_count": post.get("quote_count") or 0,
51        "url": f"https://x.com/i/status/{tweet_id}",
52    }
53
54def collect_timeline(screen_name: str, max_pages: int = 3) -> list[dict[str, Any]]:
55    rows: list[dict[str, Any]] = []
56    cursor = None
57
58    for _ in range(max_pages):
59        page = get_timeline_page(screen_name, count=20, next_cursor=cursor)
60        rows.extend(normalize_post(post) for post in page.get("data", []))
61
62        if not page.get("has_next_page"):
63            break
64        cursor = page.get("next_cursor")
65        if not cursor:
66            break
67
68    return rows
69
70if __name__ == "__main__":
71    profile = get_profile(SCREEN_NAME)
72    posts = collect_timeline(SCREEN_NAME, max_pages=2)
73    print(profile.get("screen_name") if profile else SCREEN_NAME, len(posts))

Optional Topic Search

Answer: Optional Topic Search means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

Use timeline collection when you want account posts. Use advanced search by page when you need a topic-filtered subset.

curl --request POST \
  --url https://api.twexapi.io/twitter/advanced_search/page \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "searchTerms": ["from:CerfiaFR climate"],
    "sortBy": "Latest"
  }'

Save the query with each collected row. Without that, it is hard to explain later why a post appeared in a dataset.

Data Hygiene

Answer: Data Hygiene means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

  • Record screen_name, collection time, endpoint, query, and cursor for every run.
  • Deduplicate by tweet_id.
  • Store raw JSON before normalizing fields.
  • Do not treat interaction counts as proof of accuracy or importance.
  • Review media, quoted posts, and replies before using the data in reports.

Wrap-up

Answer: Wrap-up means using TwexAPI Bearer APIs on api.twexapi.io for this user case. A typical read uses 5 Credits (about $0.05 per 1,000), and qualifying paid plans publish 20+ QPS. As of 2026-08-20, first-party developer API Post and User reads list at $5 and $10 per 1,000 resources; rate limits vary by endpoint.

For a public account such as CerfiaFR, the practical flow is: capture the profile, page through the timeline, optionally run topic-specific searches, and normalize the results into reviewable rows.

That gives you useful account data without adding unsupported claims or noisy analysis.

How to Collect Cerfia public social data via API