How to Collect Philippot X Data with TwexAPI
If you need a usable dataset from a public X account, start with the account itself. Save a profile snapshot, page through the public timeline, then run search only when you need a narrower slice such as a topic, phrase, or time-sensitive query.
This guide uses f_philippot as the example screen name. Verify the current handle before running the workflow, because public account names can change.
Collection Plan
Use three TwexAPI endpoints for this workflow:
| Task | Endpoint | When to use it |
|---|---|---|
| Get public account metadata | GET /twitter/{screen_name}/about | Capture the account snapshot before collecting posts. |
| Page through account posts | POST /twitter/{screen_name}/timeline/page | Collect recent timeline posts with cursor-based pagination. |
| Search public X results | POST /twitter/advanced_search/page | Filter the account's posts by topic, phrase, or operator. |
Keep the raw response and your normalized rows. Raw JSON gives you an audit trail if your parsing rules change later.
Get Account Metadata
curl --request GET \
--url https://api.twexapi.io/twitter/f_philippot/about \
--header 'Authorization: Bearer <token>'Store this profile snapshot separately from the post table. It can include the account id, display fields, bio fields, and public counters returned by the API.
Page Through Timeline Posts
POST /twitter/{screen_name}/timeline/page accepts count and next_cursor. For the first page, omit next_cursor. If has_next_page is true, pass the returned next_cursor into the next request.
curl --request POST \
--url https://api.twexapi.io/twitter/f_philippot/timeline/page \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"count": 20
}'The response includes the current page of data 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
This collector fetches a limited number of timeline pages and turns each post into a row you can review, deduplicate, or export.
1import os
2from typing import Any
3
4import requests
5
6TOKEN = os.environ["TWEXAPI_BEARER_TOKEN"]
7SCREEN_NAME = "f_philippot"
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
Timeline pagination is the right default when you want posts from the account. Use advanced search when you need a 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:f_philippot énergie"],
"sortBy": "Latest"
}'Save the query beside every result row. Without the query, a filtered dataset is hard to explain later.
Data Hygiene
- Record
screen_name, run time, endpoint, query, and cursor for each collection job. - Use
tweet_idas the primary deduplication key. - Save raw JSON before normalizing fields.
- Treat engagement counts as context, not as proof that a claim is accurate.
- Review quoted posts, media, and reply context before using a post in a report.
Wrap-up
For a public account such as f_philippot, the practical workflow is simple: capture account metadata, page through timeline posts, run topic search only when needed, and keep the dataset auditable.
That gives readers a repeatable data collection process without inventing performance claims, sentiment scores, or conclusions the API response does not provide.