How to get a user's posts from X (Twitter) with Python
Pass the username and page with data.next, 20 posts a page. Ten pages are 200 posts for 10 calls and $0.02; on X's own pay-per-use API, reading 200 posts is reported at about $1.
Updated 2026-11-22·This page as Markdown
Page through the posts
screen_name is the handle without @. If you store numeric user IDs, pass rest_id instead; IDs this long stay strings so they are not rounded. The cursor in data.next goes back unchanged.
X post list API·GET /v1/x/posts/list·$0.002 a call
curl "https://xtikapi.com/v1/x/posts/list?screen_name=NASA" \
-H "Authorization: Bearer YOUR_API_KEY"import requests
URL = "https://xtikapi.com/v1/x/posts/list"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
params = {"screen_name": "NASA"}
items = []
for _ in range(10): # one call per page
for attempt in range(3): # 5xx errors are not charged: retry
response = requests.get(URL, params=params, headers=HEADERS, timeout=60)
if response.status_code < 500:
break
response.raise_for_status()
data = response.json()["data"]
items += data["items"]
if not data.get("next"): # null on the last page
break
params.update(data["next"])
print(len(items), "items")const URL = "https://xtikapi.com/v1/x/posts/list";
const HEADERS = { Authorization: "Bearer YOUR_API_KEY" };
let params = {"screen_name":"NASA"};
const items = [];
for (let page = 0; page < 10; page++) {
let response;
for (let attempt = 0; attempt < 3; attempt++) {
// 5xx errors are not charged: retry
response = await fetch(`${URL}?${new URLSearchParams(params)}`, { headers: HEADERS });
if (response.status < 500) break;
}
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const { data } = await response.json();
items.push(...data.items);
if (!data.next) break; // null on the last page
params = { ...params, ...data.next };
}
console.log(items.length, "items");Recorded response (lists keep the first two items)
{
"data": {
"items": [
{
"id": "5197244563152330773",
"text": "Example text",
"author": {
"id": "41089034",
"username": "example_user",
"name": "Example name",
"avatar": "https://example.com/image.jpg",
"followers": 92213506
},
"createdAt": "2026-11-18T21:40:00.000Z",
"likeCount": 1521,
"commentCount": 63,
"shareCount": 243,
"viewCount": 218599,
"url": "https://example.com/link"
},
{
"id": "5197231336585028234",
"text": "Example text",
"author": {
"id": "41089034",
"username": "example_user",
"name": "Example name",
"avatar": "https://example.com/image.jpg",
"followers": 92213506
},
"createdAt": "2026-11-18T20:47:24.000Z",
"likeCount": 506,
"commentCount": 41,
"shareCount": 53,
"viewCount": 193300,
"url": "https://example.com/link"
}
],
"has_more": true,
"next": {
"cursor": "DAAHCgABHXc0…"
}
},
"meta": {
"request_id": "example",
"endpoint": "x.posts.list",
"normalized": true,
"unavailable": [
"cover"
],
"billing": {
"charged": true,
"amount": 0.002,
"balance": 4.98
}
}
}What the example costs
Failed calls and timeouts are not charged. A new account with a verified email gets $0.50 of trial balance, enough to run this example.
Good to know
- A page held 20 posts in our test on 2026-11-22, and page two had no overlap.
- Each post carries likes, replies, reposts and views; posts without media list
coverinmeta.unavailable. - The X comparison is in our answer on X API pricing, with its sources.
Endpoints
- X post list API · $0.002 a call
More about X
- Agent Reach Twitter/X channel stopped working: what changed?
- twikit errors (Cloudflare 403, KEY_BYTE, login 399, rate limits, bans): how do I fix them?
- twscrape errors (404, No account available, XClIdParseError, ct0, bans): how do I fix them?
- How do I convert an X (Twitter) username to its user ID (rest_id)?
- Nitter is shutting down: how else can I read X accounts without logging in?
- snscrape returns blocked (404) for Twitter: what still works?
Questions
How much does this cost with XTikAPI?
The example here is 10 calls, $0.02 in total. Failed calls and timeouts are free, and a new account with a verified email gets $0.50 of trial balance.
Do I need an X developer account?
No. The call reads public posts with an API key from this site, with no developer portal, app review or monthly plan.