Twitter (X) Conversation ID: What It Is and How to Rebuild a Reply Tree

By TwitterAPI.io Team•12 min read
Diagram of a Twitter conversation tree: a root tweet and replies at depths 1 to 3, all with conversationId equal to the root id and inReplyToId pointing to the parent
Every reply carries the root's ID as conversationId; inReplyToId gives the tree its shape.
TL;DR
  • conversation ID = root tweet ID. The root's conversationId equals its own id; every reply at any depth shares it.
  • Parent is a different field. inReplyToId points at the direct parent; that is what you use to rebuild the tree.
  • One query pulls the thread: conversation_id:<root id> on /twitter/tweet/advanced_search, 20 tweets a page, follow next_cursor.
  • Stop on an empty page, not a short one. 23 of 55 pages in our study held fewer than 20 tweets and still said has_next_page: true.
  • Expect gaps: search returned 444 of the 1,037 replies X counted (43%); 81% of what came back were direct replies to the root.
  • Cost: $0.15 per 1,000 tweets returned on TwitterAPI.io vs $0.005 per post read ($5 per 1,000) on the official X API, about 33x.

This page is about the conversation_id field itself and the reply tree it unlocks: what it is, how to read it from a tweet object, and how to turn it into a complete, ordered, deduplicated tree in code. If you just want to read an author's thread as one page, our thread reader tool and the unroll guide do that; if you want to post a thread, the thread tutorial covers writing. Here we stay on reading conversations programmatically, and we measured how well it works on live data.

Conversation IDs look trivial, and the definition is one line. The trouble starts when you rebuild a thread: replies arrive newest first, pages can be short without being the last, parents can be missing, and the reply count on the root rarely matches what you get back. We rebuilt 20 public conversations from 8 organization accounts in 2026 and report what came back, so you can size your code and your expectations before you ship.

Replies retrieved by conversation_id search vs replyCount (20 conversations, collected in 2026)

444 of 1,037 (43%)

01 — Section

What a conversation ID is (and what it is not)

X's developer documentation at docs.x.com/x-api/fundamentals/conversation-id puts it plainly: every reply on X belongs to a conversation thread, and the conversation ID is the ID of the original post that started it. The original post's conversation ID equals its own ID. No matter how deep the thread goes, all posts share the same value.

That gives you three fields to keep apart:

Field (TwitterAPI.io)Official X API v2What it holds
ididThis tweet's own ID
conversationIdconversation_idID of the root tweet of the thread
inReplyToIdreferenced_tweets (type replied_to)ID of the direct parent tweet
inReplyToUsername / inReplyToUserIdin_reply_to_user_idAuthor of the parent tweet
isReply(derived from referenced_tweets)True when the tweet answers another tweet

It is not the parent. A reply three levels down carries the root's ID in conversationId and its immediate parent's ID in inReplyToId. Code that treats conversationId as the parent flattens every thread into one level.

It is not a thread of one author. A conversation includes everyone who replied. An author's self-thread is a subset: the posts by the root author that chain through inReplyToId.

python
tweet = get_tweet("2125754695679344797")
print(tweet["id"], tweet["conversationId"], tweet["isReply"], tweet["inReplyToId"])
# a root:  id == conversationId, isReply False, inReplyToId None
# a reply: conversationId = root id, inReplyToId = direct parent id
02 — Section

How to read the conversation ID from any tweet

Every tweet object TwitterAPI.io returns, from /twitter/tweets, /twitter/user/last_tweets, /twitter/tweet/advanced_search, mentions or replies, carries conversationId as a top-level string, next to id, isReply and inReplyToId. You do not ask for it with a fields parameter. On the official X API v2 you have to request it: tweet.fields=conversation_id,in_reply_to_user_id,referenced_tweets, as the docs.x.com example shows.

From a root tweet. conversationId equals id and isReply is false. On the 160 timeline posts we pulled from the 8 accounts, every post had conversationId equal to its own id, including reposts, so the field alone does not tell a repost from an original: check retweeted_tweet first.

From a reply. conversationId is the root. If you hold a reply URL and want the whole thread, fetch the reply with /twitter/tweets?tweet_ids=<id>, read conversationId, then run the conversation search against that root. You never need to walk up the chain one parent at a time.

When it is empty. The TwitterAPI.io field reference at docs.twitterapi.io notes that conversationId may be empty. In our sample it never was (444 of 444 replies, 100%), but production code should fall back to the tweet's own id when the field is blank, which is what the code below does.

03 — Section

The official X API documents conversation_id: as a search operator: GET https://api.x.com/2/tweets/search/recent?query=conversation_id:<id> returns the replies to the original post in reverse-chronological order. The same operator works on TwitterAPI.io's /twitter/tweet/advanced_search: send query=conversation_id:<root id> and queryType=Latest, with no X developer account needed. We ran it on 20 roots and every tweet that came back shared the root's ID.

Pagination. Each page holds up to 20 tweets (fewer when non-tweet items are filtered out). Pass next_cursor back as cursor. In our run, 23 of the 55 pages held fewer than 20 tweets while still reporting has_next_page: true, and all 20 conversations ended with an empty page. So a short page is not the end; an empty page is. That last empty page is billed at the 15-credit minimum ($0.00015).

Ordering. Latest returns newest first. Tweet IDs grow over time, so sorting siblings by int(id) gives you chronological order without parsing createdAt.

Dedup. We saw 0 duplicate IDs across pages in this sample, but keep a seen set anyway: the TwitterAPI.io search docs recommend deduplicating by tweet id when you split a long collection into since_time: / until_time: windows, and a retry after a timeout can replay a page.

Only the author's posts. Add from:<handle> to the query (conversation_id:<id> from:<handle>) to get the root author's own posts in that conversation, which is how you rebuild a self-thread. Expect the author's replies to commenters in the result too; keep only the chain that links back to the root through the author's own posts.

python
def author_thread(root_id, author_handle):
    """The root author's own posts in a conversation: their thread plus their replies to others."""
    seen, out, cursor = set(), [], ""
    while True:
        r = requests.get(f"{BASE}/twitter/tweet/advanced_search", headers=HEADERS,
                         params={"query": f"conversation_id:{root_id} from:{author_handle}",
                                 "queryType": "Latest", "cursor": cursor}, timeout=30)
        r.raise_for_status()
        body = r.json()
        new = [t for t in body.get("tweets") or [] if t["id"] not in seen]
        seen.update(t["id"] for t in new)
        out += new
        cursor = body.get("next_cursor") or ""
        if not body.get("has_next_page") or not cursor or not new:
            return out
04 — Section

Rebuild the reply tree: depth, ordering and orphans

Search gives you a flat list. The tree comes from one pass: index every tweet by id, then attach each reply to children[inReplyToId]. A reply whose parent is the root has depth 1; a reply to that reply has depth 2, and so on. Anything whose parent is neither the root nor in your list is an orphan: the parent was deleted, sits on a protected account, or was not returned by search.

Across the 444 replies we retrieved, 361 (81.3%) answered the root directly, 49 sat at depth 2, 8 at depth 3 and 14 at depth 4 or deeper. 12 replies (2.7%) had a parent we never saw. Nested replies showed up in 8 of the 20 conversations, and the deepest chain ran 8 levels, in a PlayStation conversation.

Keep orphans, do not drop them. Attach them under a synthetic "missing parent" node or at depth 1 with a flag. Dropping them silently loses real replies, and they are often the start of a sub-thread.

Guard against loops. IDs only point backwards in time, so a true cycle cannot happen, but malformed or partial data can still produce a self-reference. A depth cap (we used 50) costs nothing.

Where the root author speaks. Only 1.4% of retrieved replies came from the root account itself, and 5 of the 20 conversations had any reply from the root author at all. For brand accounts, the conversation is almost entirely the audience; the author's own presence is easy to spot by comparing author.id with the root's author.

Bar chart of reply depth in 444 replies from 20 Twitter conversations: 361 direct replies, 49 at depth 2, 8 at depth 3, 14 at depth 4 or deeper, 12 with a missing parent
Reply depth across 20 public conversations, collected in 2026: 81% of replies answer the root directly; the deepest chain ran 8 levels.
05 — Section

replyCount vs what you can retrieve

This is the number that surprises people. The root tweet's replyCount is X's counter. Conversation search returns the replies it can find. Across our 20 conversations the counters added up to 1,037 and search returned 444, which is 43%. The median conversation returned 40%, with a range from 11% to 95%.

AccountreplyCountRetrievedShareMax depth
@PlayStation1208470%8
@PlayStation1196050%7
@nvidia1092321%1
@nvidia903539%3
@PlayStation864552%3
@NASA822227%1
@nvidia802228%1
@Xbox622540%2

The table shows the 8 conversations with the largest counters; the chart shows all 20.

We cannot tell from the data which replies are missing or why. Candidate explanations a developer should plan for: replies from protected accounts are counted but not public, deleted replies may still be in the counter, and X hides some replies behind its "show more replies" ranking. Running the same query with queryType=Top on 5 of the roots added 17 replies that Latest had not returned (158 unique vs 141), so the two orders together see a little more, but neither gets near the counter.

What to do with it. Store replyCount and your retrieved count side by side. Report coverage as a ratio instead of promising "all replies". If you need every reply that is still public, run both Latest and Top, union by id, and re-run the search later for late replies.

Dot plot comparing replyCount with replies retrieved by conversation_id search for 20 Twitter conversations; 444 of 1,037 retrieved
replyCount on the root vs replies returned by conversation_id search, 20 conversations from 8 organization accounts, collected in 2026.
06 — Section

Conversation search vs thread_context vs the replies endpoint

TwitterAPI.io has two other endpoints that touch threads. We called each once on 5 of the roots and compared what came back with the conversation search.

RootSearch (Latest)Search directthread_context p1replies p1
@NASA (51 counted)1010109
@PlayStation (120 counted)84493620
@github (58 counted)16151720
@nvidia (80 counted)22202017
@vercel (16 counted)99109

/twitter/tweet/thread_context. Per its docs, given a reply it returns the chain above it and the replies below it (t1 to t6 in the docs example). Called on a root, its first page held only direct replies in 4 of the 5 roots. Use it to walk up from a deep reply to see its ancestors; do not use it to download a whole tree, because nested replies need one call per branch.

/twitter/tweet/replies. One page held up to 20 replies; in 3 of 5 roots it mixed nested replies in, and on the GitHub root 7 of its 20 replies were not in the conversation search result. That makes it a useful second source when coverage matters: union its IDs with the search.

Conversation search. The only one of the three that returns the whole tree from one query, at every depth, with inReplyToId on each tweet so you can rebuild the structure. Start here.

07 — Section

Cost: TwitterAPI.io vs the official X API

Conversation search is a tweet endpoint: 15 credits per tweet returned, $0.15 per 1,000 tweets, with a 15-credit ($0.00015) minimum per request. A full 20-tweet page costs $0.003, and the empty page that ends each conversation costs the $0.00015 minimum. No X developer account is needed for reads.

The official X API's pay-per-usage rate card at docs.x.com/x-api/getting-started/pricing lists $0.005 per post read, or $5 per 1,000, with post reads capped at 3 million per monthly billing cycle (Enterprise above that). Its recent search covers the last 7 days for all developers; full-archive search is for pay-per-use and Enterprise customers.

Conversation sizePagesTwitterAPI.ioOfficial X API (post reads)
20 replies1 full + 1 empty$0.00315$0.10
100 replies5 full + 1 empty$0.01515$0.50
1,000 replies50 full + 1 empty$0.15015$5.00

Per 1,000 tweets that is $5 / $0.15, about 33x. Our whole study, 88 requests that returned 908 tweets across timelines, searches and comparison calls, cost about $0.14 in credits. See /pricing for subscriptions and the free starter credits (no card, one per person or network, expiring after 31 days) that new accounts get after the automatic bot check.

Polling a live conversation. If you re-run the search to catch new replies, a check that finds nothing costs the $0.00015 minimum: every 60 seconds for a month is 43,200 checks, $6.48; every 5 minutes is $1.30. Add since_id:<newest reply id> to the query so each check only returns new replies.

08 — Section

Replying inside a conversation (write calls)

Reading a conversation needs no X account. Replying into one is a write, and writes on TwitterAPI.io run through an authenticated session: one /twitter/user_login_v2 login ($0.10, with a proxy you supply) returns login_cookies, and /twitter/create_tweet_v2 with a reply_to_tweet_id posts the reply. Each successful write is 60 credits ($0.0006) per successful call; calls that return status: error are not charged.

It acts as that account. X can rate-limit, lock or suspend it. Reply only from your own account, at a normal human pace; X's automation rules apply, and this is not a way around any limit. The session can need a re-login. On the official X API a post create is $0.015 per request on the same rate card.

To reply to the right tweet, use the reply's own id as reply_to_tweet_id, not the conversationId: replying to the conversation ID answers the root, not the person you meant. Our reply tutorial covers the full write flow.

09 — Section

How we collected this

Question. When you rebuild a conversation from its conversation ID, how much of replyCount comes back, how deep are the trees, how many replies are direct, how often does the root author reply, and what do the other thread endpoints return?

Accounts and selection. The latest 20 timeline posts of 8 organization accounts: NASA, GitHub, Vercel, OpenAIDevs, NVIDIA, Xbox, PlayStation and Docker. From each, up to 3 original posts (no reposts, no replies) with a replyCount between 5 and 120, for 20 roots in total.

Method. /twitter/user/last_tweets (1 page per account), then /twitter/tweet/advanced_search with query=conversation_id:<root id> and queryType=Latest, following next_cursor until an empty page. On 5 roots we also called /twitter/tweet/thread_context, /twitter/tweet/replies and the Top search. Trees rebuilt by linking inReplyToId inside the retrieved set. 88 requests in total, collected in 2026.

Sample. 20 conversations, 1,037 replies counted by X, 444 retrieved. Just over half of the retrieved replies (52%) arrived within an hour of the root and 96% within a day.

What the sample cannot show. It covers recent posts from brand accounts with modest reply counts; viral threads with thousands of replies, older conversations and political or news threads may behave differently. It cannot say why a counted reply is missing. One collection pass, no re-runs over time.

Privacy. Aggregates only. Root accounts are organizations; reply authors are mostly private individuals, so their posts are not stored with the study, and the published sample keeps only de-identified rows (depth, whether the root author wrote it, minutes after the root).

python
import requests
from collections import defaultdict

API_KEY = "YOUR_API_KEY"
BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": API_KEY}


def get_tweet(tweet_id):
    r = requests.get(f"{BASE}/twitter/tweets", headers=HEADERS,
                     params={"tweet_ids": tweet_id}, timeout=30)
    r.raise_for_status()
    tweets = r.json().get("tweets") or []
    return tweets[0] if tweets else None


def conversation(root_id, max_pages=50):
    """Every tweet that search returns for conversation_id:<root_id>, deduplicated by id."""
    seen, out, cursor = set(), [], ""
    for _ in range(max_pages):
        r = requests.get(f"{BASE}/twitter/tweet/advanced_search", headers=HEADERS,
                         params={"query": f"conversation_id:{root_id}",
                                 "queryType": "Latest", "cursor": cursor}, timeout=30)
        r.raise_for_status()
        body = r.json()
        new = [t for t in body.get("tweets") or [] if t["id"] not in seen]
        for t in new:
            seen.add(t["id"])
            out.append(t)
        cursor = body.get("next_cursor") or ""
        # a short page can still say has_next_page=true; stop on an empty page
        if not body.get("has_next_page") or not cursor or not new:
            break
    return out


def build_tree(root_id, tweets):
    children = defaultdict(list)
    by_id = {t["id"]: t for t in tweets}
    orphans = []
    for t in tweets:
        if t["id"] == root_id:
            continue
        parent = t.get("inReplyToId")
        if parent == root_id or parent in by_id:
            children[parent].append(t)
        else:
            orphans.append(t)  # parent not returned (deleted, protected or not indexed)
    for kids in children.values():
        kids.sort(key=lambda x: int(x["id"]))  # tweet ids grow with time
    return children, orphans


def print_tree(node_id, children, depth=1):
    for t in children.get(node_id, []):
        text = t["text"].replace("\n", " ")[:70]
        print("  " * depth + f"[{depth}] @{t['author']['userName']}: {text}")
        print_tree(t["id"], children, depth + 1)


if __name__ == "__main__":
    any_tweet_in_thread = "2125754695679344797"   # a root or any reply
    tweet = get_tweet(any_tweet_in_thread)
    root_id = tweet["conversationId"] or tweet["id"]
    root = tweet if root_id == tweet["id"] else get_tweet(root_id)
    replies = conversation(root_id)
    children, orphans = build_tree(root_id, replies)
    found = sum(len(v) for v in children.values()) + len(orphans)
    print(f"root {root_id}: replyCount={root['replyCount'] if root else '?'}, retrieved={found}, "
          f"orphans={len(orphans)}")
    print_tree(root_id, children)

Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.

10 — Questions

Questions readers ask

What is a conversation ID on Twitter (X)?

It is the tweet ID of the post that started a thread. The root tweet's conversation ID equals its own ID, and every reply in that thread, at any depth, carries the same value. X's developer docs define it as the ID of the original post that started the conversation.

Is the conversation ID the same as the tweet ID?

Only for the root tweet. For a reply, the conversation ID is the root's ID, while the reply's own ID is different and its direct parent sits in inReplyToId (or referenced_tweets on the official X API).

How do I get all replies to a tweet with the API?

Read the tweet's conversationId, then call /twitter/tweet/advanced_search with query=conversation_id:<root id> and queryType=Latest, follow next_cursor until a page comes back empty, and deduplicate by id. In our study this returned 43% of the replies X counted, so treat it as the replies visible to search.

Why does replyCount not match the replies I retrieve?

The counter is X's number; search returns the replies it can find. Protected accounts, deleted replies and replies X ranks lower are possible reasons. Across 20 conversations we retrieved 444 of 1,037 counted replies; combining Latest and Top added a few more.

How do I find the root tweet from a reply?

Fetch the reply with /twitter/tweets?tweet_ids=<id> and read conversationId; that is the root's ID. Use /twitter/tweet/thread_context if you want the chain of ancestors between the reply and the root.

How do I get only the original author's thread?

Add from:<handle> to the query: conversation_id:<root id> from:<handle>. The result includes the author's replies to other people too, so keep the chain that links back to the root through the author's own posts.

How much does it cost to fetch a conversation?

On TwitterAPI.io, 15 credits per tweet returned ($0.15 per 1,000), with a $0.00015 minimum per request; a 100-reply conversation is about $0.015. The official X API lists $0.005 per post read, so the same 100 replies cost $0.50 there.

11 — Further reading

Continue

Sources & further reading
More from this series

Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.

Build it

Stop reading. Start building.

Starter credits cover real testing on real data. Google sign-in, no card, no application queue.

Get an API key

Already building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.