How to read the replies to a tweet programmatically

Updated
Read the public replies to any X post from code or an agent: a post lookup plus a conversation_id search on the UnifAPI X API or MCP, sorted and paged.
In short: the replies to an X post take two calls on the paid UnifAPI X API.
GET /x/tweets/{id}returns the original post (1 credit), andGET /x/tweets/search/recent?query=conversation_id:<id>returns the public posts in its conversation, 1 credit per post returned. Agents make the same calls through the UnifAPI MCP server (OAuth sign-in, no key to paste); code sends a workspace key as a Bearer token. Drop the original from the search results, sort onpublic_metricsfor "top" or oncreated_atfor "recent", and page withpagination_token. Records use the X API v2 field names. For a person, the reply viewer stays free in a browser, with no login, rate-limited per visitor.
The replies under a post are where the reaction lives. The post itself tells you what a brand said; the replies tell you what people think of it, what broke, what they want, and which complaint got 4,000 likes. For sentiment work, customer research, and incident monitoring they are the data.
They are also the hardest part of X to read without an account. FxTwitter and vxTwitter read one post. The syndication endpoint reads one post. X's own page loads replies with JavaScript after the fact, so curl gets an empty shell. The official API exposes replies through conversation search on paid tiers. That gap is why most "read this thread" agent tasks used to end in a headless browser.
The request
If you used the old free endpoints under /tools/x/: since October 17, 2026, those URLs answer scripts and agents with HTTP 402, and the body names the MCP server and the paid operations that replace each lookup (for replies, the two calls below). The viewer pages stay free in a browser. Through the MCP server at https://mcp.unifapi.com or the X API, a call bills 1 credit ($0.001) per returned record and at least 1 credit, so a post with one page of 20 replies costs 21 credits ($0.021).
From an agent. Connect the UnifAPI MCP server at https://mcp.unifapi.com. Your client asks you to sign in with OAuth; there is no key to paste, and calls spend workspace credits, pay as you go. Per-client setup for Claude, ChatGPT, Cursor, Codex and others is on the MCP setup page. The agent finds the operations with list_operations and get_operation, then makes two call_api calls, first the post, then its conversation:
{ "path": "/x/tweets/2107237881668313108", "method": "GET" }
{
"path": "/x/tweets/search/recent",
"method": "GET",
"query": { "query": "conversation_id:2107237881668313108", "max_results": 20 }
}
From code. The same two calls over HTTP, with a workspace API key:
curl -s -H "Authorization: Bearer $UNIFAPI_API_KEY" \
"https://api.unifapi.com/x/tweets/2107237881668313108"
curl -s -G -H "Authorization: Bearer $UNIFAPI_API_KEY" \
"https://api.unifapi.com/x/tweets/search/recent" \
--data-urlencode "query=conversation_id:2107237881668313108" \
--data-urlencode "max_results=20"
Both take the numeric post id, the digits after /status/ in the post URL. To get a key, sign in at https://api.unifapi.com/sign-in, top up on the dashboard's Billing page and create one on its API keys page; the Connect button on the reply viewer does all three in one flow.
The post comes back as one object in data (trimmed):
{
"request_id": "…",
"data": {
"id": "2107237881668313108",
"text": "Time to bring them home 🌎 …",
"conversation_id": "2107237881668313108",
"public_metrics": {
"like_count": 7210,
"retweet_count": 846,
"reply_count": 262,
"quote_count": 60,
"bookmark_count": 197,
"impression_count": 2823329
},
"author": { "username": "NASA", "name": "NASA", "verified": true }
},
"billing": {
"credits_charged": 1,
"records_charged": 1,
"balance_remaining": 1999,
"truncated_due_to_balance": false
}
}
The conversation comes back as an array in data, with pagination (trimmed to one reply):
{
"request_id": "…",
"data": [
{
"id": "2107252849688424504",
"text": "@NASA @Space_Station @SpaceX Those space suits don't look right…",
"created_at": "Mon Oct 05 23:33:22 +0000 2026",
"conversation_id": "2107237881668313108",
"public_metrics": {
"like_count": 15,
"retweet_count": 1,
"reply_count": 0,
"quote_count": 0,
"bookmark_count": 0,
"impression_count": 894
},
"author": {
"username": "Troyztoys",
"name": "Tee Crenshaw",
"verified": true,
"public_metrics": { "followers_count": 1823 }
}
}
],
"pagination": { "has_more": true, "next_cursor": "…" },
"billing": {
"credits_charged": 20,
"records_charged": 20,
"balance_remaining": 1979,
"truncated_due_to_balance": false
}
}
The search returns the public posts whose conversation_id is the original's id, direct replies and nested ones alike. The original's conversation_id is its own id, so it can come back in the results too: drop the record whose id equals the post id. What is left is the replies.
Sorting
The search has no sort parameter, so sort the replies yourself on the fields every record carries. "Top" is likes plus reposts plus replies (like_count + retweet_count + reply_count), roughly what X's own "Most relevant" tab does. "Recent" is created_at, newest first. created_at arrives in X's own format (Mon Oct 05 23:33:22 +0000 2026), so parse it to a date before comparing; string order is not time order.
With replies holding the search records minus the original:
const score = (t) =>
(t.public_metrics?.like_count ?? 0) +
(t.public_metrics?.retweet_count ?? 0) +
(t.public_metrics?.reply_count ?? 0);
const top = [...replies].sort((a, b) => score(b) - score(a));
const recent = [...replies].sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at));
A sort ranks only what you have fetched. X's search decides the order pages arrive in, so to rank a whole conversation, collect its pages first. For "what is the reaction" use top; for "what happened in the last hour" use recent.
The human page, /tools/x-reply-viewer, has the same two orders as pills, and /tools/x-reply-viewer?q= with a post id or URL opens it on that post.
Paging
When pagination.has_more is true, pass pagination.next_cursor back as pagination_token with the same query to get the next page. Treat the cursor as an opaque string. max_results (1 to 100) caps how many posts a page returns, and so what the page costs. In Node 18 or later, as an ES module:
const API = "https://api.unifapi.com";
const headers = { Authorization: `Bearer ${process.env.UNIFAPI_API_KEY}` };
const id = "2107237881668313108";
async function get(path, query = {}) {
const url = new URL(path, API);
for (const [k, v] of Object.entries(query)) if (v) url.searchParams.set(k, String(v));
const res = await fetch(url, { headers });
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error?.type}: ${body.error?.message}`);
return body;
}
const post = (await get(`/x/tweets/${id}`)).data;
const replies = [];
let cursor;
do {
const page = await get("/x/tweets/search/recent", {
query: `conversation_id:${id}`,
max_results: 20,
pagination_token: cursor,
});
replies.push(...page.data.filter((t) => t.id !== id));
cursor = page.pagination?.has_more ? page.pagination.next_cursor : undefined;
} while (cursor && replies.length < 100);
The loop stops at 100 replies; raise the cap when you want the whole conversation. A post with 262 replies is about 14 pages of 20. Walking all of them is 15 requests and roughly one credit per reply plus one for the post, about 263 credits ($0.26) if every reply is readable. The top replies by engagement are usually what matters, so stop when you have enough.
What a reply record contains
| Field | Meaning |
|---|---|
id | The reply's id; the post URL is https://x.com/<username>/status/<id> |
text | Full text, with leading @mentions as X stores them |
created_at | When it was posted, in X's format (Mon Oct 05 23:33:22 +0000 2026) |
author_id, author | The author's id, and the author as a user record: username, name, verified, public_metrics, … |
public_metrics | like_count, retweet_count, reply_count, quote_count, bookmark_count, impression_count |
attachments.media_keys, media | Photos and videos: type, url, preview_image_url, width, height, MP4 variants on X's CDN |
conversation_id | The root post of the conversation |
lang | X's language code for the text |
possibly_sensitive | X's own flag |
edit_history_tweet_ids | The ids of the post's versions (only its own id if it was never edited) |
There is no parent field: a record says which conversation it belongs to, not which post it answers. The leading @mentions in text show whom a reply addresses.
The shape is the same XTweet record that search, timelines and single-post lookups return, so a function that scores a post works on a reply unchanged.
Three things to build
A reaction summary. Fetch the original and one page of 20 replies (21 credits, about two cents), sort by engagement, feed the texts to a model with the original post, and ask for the three most common sentiments with one representative quote each. For a big conversation, read a few pages before you rank, since the sort sees only what you fetched.
A complaint feed. For a brand's announcement, re-read the conversation every 10 minutes, keep each reply's like_count by id, and route the replies that climb past a threshold between polls to a human. The rising ones are the ones that will be screenshotted. X's search operators work in the query, so conversation_id:<id> min_faves:50 returns, and bills, only the replies with at least 50 likes. Every poll bills what it returns: one 20-reply page every 10 minutes is 2,880 credits ($2.88) a day.
A thread transcript. Walk all pages, sort by created_at oldest first, and render each reply as a Markdown line with the author's username, the text, like_count and the post URL. Records carry no parent id, so the transcript is chronological rather than a tree; the leading @mentions show who answers whom. For the 262-reply post that is about 263 credits for a readable record of the conversation in a report.
Pricing and limits
- Credits. 1 credit per returned record, minimum 1 credit per call; a credit is $0.001 (1,000 credits = $1). The original post is 1 credit. A search page bills 1 credit per post it returns, the original included when it comes back; a page of 20 is 20 credits ($0.02). The author inside each reply comes with it and is not billed separately. No subscription.
- Balance. Your balance caps how many records a page returns (
billing.truncated_due_to_balancesays when it did), and it never goes negative. When it cannot cover even one record, the call gets a 402insufficient_creditserror with a top-up path. - Rate limit. 60 requests per minute per key by default. Every response carries
RateLimit-*andX-RateLimit-*headers; a 429rate_limitedcarriesRetry-After. - Public replies only. Replies from protected accounts and deleted replies are not included, and the
reply_counton the original post can be higher than what is readable for that reason. Replies come from X's recent search, so the set is what that search returns for the conversation.
The full parameter and field reference is on the X / Twitter API page.
FAQ
Can I get the replies to a tweet without the Twitter API?
To read them yourself, yes: the reply viewer is free in a browser, with no login and no account, and rate-limited per visitor. From code or an agent, use the UnifAPI X API or MCP server above: pay as you go with UnifAPI credits, no X developer account.
Why does X say 262 replies but I only see 200?
Some replies are from protected accounts, some were deleted, and some are hidden by the author. The count on the original post is X's, the readable set is what is public, and you are billed only for the records that come back.
Does it include quote posts?
No. Quotes are separate posts, not replies. GET /x/tweets/{id}/quote_tweets returns the quote posts of a post, in the same record shape.
Can I read replies as text for a model?
Yes. Through MCP, the agent reads the JSON that call_api returns directly. From code, keep the author's username, the text and like_count for each reply and join them into one prompt, with the original post first.