Build a Twitter (X) Clone in Next.js with Real Data
![Architecture diagram of a Twitter-style clone in Next.js. Left column: pages /, /[user] and /status/[id]. Middle column: route handlers /api/feed (revalidate 600 s), /api/user (revalidate 3600 s) and /api/thread (revalidate 30 s). Right column: twitterapi.io endpoints /twitter/user/last_tweets, /twitter/user/info and /twitter/tweet/advanced_search with conversation_id.](/blog/twitter-clone/hero.png)
- Three pages, three routes:
/(feed),/[user](profile + timeline),/status/[id](post + replies); each page reads a Next.js route handler that callsapi.twitterapi.iowith theX-API-Keyheader on the server. - Real endpoints:
/twitter/user/last_tweets(20 posts a page,has_next_page+next_cursor),/twitter/user/info(profile header),/twitter/tweet/advanced_searchwithconversation_id:<id>(replies). - Map to a slim
Posttype before sending JSON to the browser: in our sample that cut a page of 20 from 155 KB to 11.5 KB (92.6% smaller). - Render real shapes: 37.6% of posts had media, 31.9% a link card, 24.1% were reposts and 5.1% quotes; 17.0% of original posts were longer than 280 characters, so build a "Show more" fold.
- Cache by route:
next: { revalidate: 600 }on the first feed page, an hour for profiles and older pages; the organization timelines we sampled posted between 0.05 and 2.67 times a day. - Cost: $0.15 per 1,000 posts returned, $0.18 per 1,000 profiles; the official X API lists $0.005 per post read, about 33x more per 1,000 posts.
This page builds a web Twitter clone with Next.js and React. If you are building a mobile clone in Flutter and Dart, the sibling guide on a Flutter Twitter clone covers that stack; and if you only want to show existing tweets on a site with an embed component, the Twitter React guide is the shorter path. Here the goal is an original microblog-style app of your own, with its own design and name, that renders a feed, profiles and threads from real public X data. It is not an official X product and should not copy X's logo or branding.
Search for "twitter clone" and the results are mostly full-stack tutorials and GitHub repositories (Next.js with Prisma, Firebase or MongoDB) where you sign up, post to a global feed and follow your own test users. That is a good exercise in auth and CRUD, but the feed is empty until you seed it, and seed data never has the awkward parts of a real timeline: reposts wrapping another author, quoted posts, video, link cards, posts longer than 280 characters, reply trees two or three levels deep and pages that are much heavier than you expect.
So we did the measuring first. We pulled 960 recent posts from six public organization accounts (vercel, nextjs, reactjs, github, supabase, NASA) plus one live conversation, and used the numbers to choose the data model, the paging logic and the caching times below. Every number on this page comes from that study, collected in 2026 with 53 read requests that cost about $0.15 in total.
155 KB at the median, 11.5 KB after mapping to a slim Post model (92.6% smaller), measured on 48 pages from 6 organization accounts, collected in 2026.
What a Twitter clone usually fakes, and what you can load live
A clone has two halves. The social graph and write path (sign-up, your own posts, follows inside your app) belong to your database. The content half (what a timeline, a profile header and a reply thread actually look like) can come from real public X data. The table shows which screens a typical tutorial seeds by hand and which read endpoint fills them with live data instead.
Keep your own users separate. Posts written inside your clone live in your database and never pretend to be on X. Live X data is read-only content you display with attribution (author name, handle and a link to the original post). That split keeps the app honest and keeps the tutorial focused on the hard rendering problems.
Why server-side. The API key is a secret, so every call to api.twitterapi.io runs in a Next.js route handler or server component. The browser only ever talks to your own /api/... routes. That also gives you one place to cache, which matters for cost and payload size, as the study below shows.
Step 1: create the Next.js app and keep the key on the server
Create an App Router project (npx create-next-app@latest clone --ts --app), add your key to .env.local as TWITTERAPI_IO_API_KEY=..., and never give it the NEXT_PUBLIC_ prefix: Next.js inlines NEXT_PUBLIC_ variables into the browser bundle. Route handlers read process.env.TWITTERAPI_IO_API_KEY at request time on the server.
Plan three route handlers. app/api/feed/route.ts returns one page of a user timeline, app/api/user/route.ts returns a profile, and app/api/thread/route.ts returns a reply tree. The Next.js route.js reference shows the shape: export async function GET(request: NextRequest), with query parameters on request.nextUrl.searchParams.
Caching is opt-in. Per the Next.js docs (nextjs.org/docs/app/api-reference/file-conventions/route), the default caching for GET route handlers changed from static to dynamic in v15, and the fetch reference says next: { revalidate: n } sets the cache lifetime of a resource in seconds (the cached copy is reused for no longer than that). We set an explicit revalidate on every upstream fetch so cost and freshness are decisions, not defaults.
Validate input before it reaches the API. A user handle is 1 to 15 letters, digits or underscores; a post id is digits. Rejecting anything else in the route keeps junk requests (and their minimum charge) away from the upstream API.
Step 2: define one typed Post model and map raw tweets to it
The raw tweet object is rich: counts, entities, media variants, card data, the full author object with dozens of profile fields, and nested retweeted_tweet and quoted_tweet objects that repeat all of that. In our sample, a page of 20 posts was 155 KB of compact JSON at the median (183 KB at p90, 214 KB at the max). Sending that to a phone for every scroll step is waste.
Mapping each post to the slim Post type below (id, text, time, four counts, a four-field author, media URLs, one level of repost or quote) brought the median page down to 11.5 KB, a 92.6% reduction, measured on the same 48 pages. The mapper reads the field names exactly as the API returns them: likeCount, retweetCount, replyCount, viewCount, extendedEntities.media[].media_url_https, author.profilePicture.
Recursion stops at one level. A repost contains the original post; a quote contains another post that can itself quote. A card in a feed only needs one inner level, so the mapper passes depth and drops deeper nesting.
Keep inReplyToId and conversationId. The thread page needs them to place each reply under its parent.
// lib/post.ts - the one Post shape every page in the clone renders
export type Post = {
id: string;
text: string;
createdAt: string; // "Thu Oct 16 12:34:56 +0000 2026"
likeCount: number;
retweetCount: number;
replyCount: number;
viewCount: number | null;
author: { userName: string; name: string; avatar: string | null; isBlueVerified: boolean };
media: { type: "photo" | "video" | "animated_gif"; url: string }[];
repostOf: Post | null; // retweeted_tweet, rendered as "reposted"
quoted: Post | null; // quoted_tweet, rendered as an inner card
inReplyToId: string | null;
conversationId: string | null;
};
// Map one raw tweet object from api.twitterapi.io to the slim Post.
// Field names are read exactly as the API returns them (camelCase on tweets).
export function toPost(t: any, depth = 0): Post {
const a = t.author ?? {};
return {
id: t.id,
text: t.text ?? "",
createdAt: t.createdAt,
likeCount: t.likeCount ?? 0,
retweetCount: t.retweetCount ?? 0,
replyCount: t.replyCount ?? 0,
viewCount: t.viewCount ?? null,
author: {
userName: a.userName,
name: a.name,
avatar: a.profilePicture ?? null,
isBlueVerified: Boolean(a.isBlueVerified),
},
media: (t.extendedEntities?.media ?? []).map((m: any) => ({
type: m.type,
url: m.media_url_https,
})),
// one level of nesting is enough for a card; stop recursion there
repostOf: t.retweeted_tweet && depth === 0 ? toPost(t.retweeted_tweet, 1) : null,
quoted: t.quoted_tweet && depth === 0 ? toPost(t.quoted_tweet, 1) : null,
inReplyToId: t.inReplyToId ?? null,
conversationId: t.conversationId ?? null,
};
}Step 3: the feed route with cursor paging and caching
Per the twitterapi.io reference for /twitter/user/last_tweets, the endpoint returns a user's posts "newest first" with up to 20 per page; the first page takes an empty cursor, and has_next_page and next_cursor sit at the top level of the response while the posts are in data.tweets. The pinned post comes separately as data.pin_tweet (or null). Replies are excluded unless you pass includeReplies=true.
The route below proxies one page, maps it to Post, and returns nextCursor only when has_next_page is true. The first page revalidates every 10 minutes; older pages change rarely and revalidate hourly. An unknown account does not return 404: the body has status: "error" and a msg, so the route checks that field, not just the HTTP status.
Do not trust deep paging to be continuous. In our sample, NASA's timeline jumped from posts in 2026 to posts in 2022 between two consecutive pages: the largest gap between neighboring posts was 1,151.1 days. A clone should show what it gets in order and never infer "no posts in this period" from a gap.
// app/api/feed/route.ts - server-only proxy: the API key never reaches the browser
import { type NextRequest } from "next/server";
import { toPost } from "@/lib/post";
const BASE = "https://api.twitterapi.io";
export async function GET(request: NextRequest) {
const userName = request.nextUrl.searchParams.get("user") ?? "vercel";
const cursor = request.nextUrl.searchParams.get("cursor") ?? "";
if (!/^[A-Za-z0-9_]{1,15}$/.test(userName)) {
return Response.json({ error: "bad user" }, { status: 400 });
}
const url = new URL(`${BASE}/twitter/user/last_tweets`);
url.searchParams.set("userName", userName);
url.searchParams.set("cursor", cursor);
const res = await fetch(url, {
headers: { "X-API-Key": process.env.TWITTERAPI_IO_API_KEY! },
next: { revalidate: cursor ? 3600 : 600 }, // first page 10 min, older pages 1 h
});
if (!res.ok) {
return Response.json({ error: `upstream ${res.status}` }, { status: 502 });
}
const body = await res.json();
if (body.status === "error") {
return Response.json({ error: body.msg }, { status: 502 });
}
return Response.json({
posts: (body.data?.tweets ?? []).map((t: any) => toPost(t)),
pinned: body.data?.pin_tweet ? toPost(body.data.pin_tweet) : null,
nextCursor: body.has_next_page ? body.next_cursor : null,
});
}Step 4: the profile page and an infinite feed
The profile page is a server component. It fetches the header from /twitter/user/info and the first feed page in parallel, renders both on the server, and hands the first page to a small client component that loads more on demand. In Next.js 15 and later the page params is a promise, so it is awaited first.
/twitter/user/info returns data with name, userName, description, location, followers, following, statusesCount, createdAt, isBlueVerified, profilePicture and coverPicture. An unknown handle returns HTTP 200 with status: "error", msg: "user not found" and data: null, which the page turns into a friendly empty state.
Load more, not auto-scroll, to start. A button driven by nextCursor is accessible by keyboard, easy to test, and cannot fire ten requests in a second on a fast scroll. You can swap in an IntersectionObserver later. The client dedupes by id when appending, and ignores clicks while a request is in flight.
Render times from createdAt. It arrives as a string like Thu Oct 16 12:34:56 +0000 2026; Date.parse handles it, and Intl.RelativeTimeFormat gives the "3h" style label.
// app/[user]/page.tsx - server component: profile header + first feed page
import { Feed } from "./Feed";
import { toPost } from "@/lib/post";
const BASE = "https://api.twitterapi.io";
const H = { "X-API-Key": process.env.TWITTERAPI_IO_API_KEY! };
export default async function ProfilePage({ params }: { params: Promise<{ user: string }> }) {
const { user } = await params; // params is a promise since Next.js 15
const [infoRes, feedRes] = await Promise.all([
fetch(`${BASE}/twitter/user/info?userName=${encodeURIComponent(user)}`, { headers: H, next: { revalidate: 3600 } }),
fetch(`${BASE}/twitter/user/last_tweets?userName=${encodeURIComponent(user)}`, { headers: H, next: { revalidate: 600 } }),
]);
const info = await infoRes.json();
if (info.status === "error" || !info.data) {
return <p>This account does not exist or is not available.</p>; // unknown user: HTTP 200 + status "error"
}
const feed = await feedRes.json();
const u = info.data;
return (
<main>
<header>
<h1>{u.name}</h1>
<p>@{u.userName}{u.isBlueVerified ? " (verified)" : ""}</p>
<p>{u.description}</p>
<p>{u.following.toLocaleString()} following, {u.followers.toLocaleString()} followers</p>
</header>
<Feed
user={u.userName}
first={{
posts: (feed.data?.tweets ?? []).map((t: any) => toPost(t)),
nextCursor: feed.has_next_page ? feed.next_cursor : null,
}}
/>
</main>
);
}
// app/[user]/Feed.tsx - client component with "Load more" driven by nextCursor
"use client";
import { useState } from "react";
import type { Post } from "@/lib/post";
import { PostCard } from "@/components/PostCard";
export function Feed({ user, first }: { user: string; first: { posts: Post[]; nextCursor: string | null } }) {
const [posts, setPosts] = useState(first.posts);
const [cursor, setCursor] = useState(first.nextCursor);
const [loading, setLoading] = useState(false);
async function loadMore() {
if (!cursor || loading) return; // ignore double clicks
setLoading(true);
try {
const r = await fetch(`/api/feed?user=${user}&cursor=${encodeURIComponent(cursor)}`);
const page = await r.json();
setPosts((prev) => {
const seen = new Set(prev.map((p) => p.id)); // pages can overlap: dedupe by id
return [...prev, ...page.posts.filter((p: Post) => !seen.has(p.id))];
});
setCursor(page.nextCursor);
} finally {
setLoading(false);
}
}
return (
<section aria-label={`Posts by @${user}`}>
{posts.map((p) => <PostCard key={p.id} post={p} />)}
{cursor && (
<button onClick={loadMore} disabled={loading} className="load-more">
{loading ? "Loading..." : "Load more"}
</button>
)}
</section>
);
}Step 5: the post page and its reply tree
A post page shows the root post and the conversation under it. Rebuild that with conversation search: /twitter/tweet/advanced_search with query=conversation_id:<root id> and queryType=Latest returns the replies in the conversation, 20 or fewer per page, with tweets, has_next_page and next_cursor at the top level. Group them by inReplyToId and render children under each parent. The conversation ID guide explains where that id comes from.
We ran this on one recent vercel post whose replyCount was 229. Conversation search returned 40 replies across 2 pages before has_next_page turned false. Of those, 26 answered the root and 14 (35.0%) answered another reply, so a flat comment list would have misplaced about a third of the thread. The 40 replies came from 30 distinct accounts.
Show the count you are given, render what you receive. replyCount on the root (229) and the number of replies the search returned (40) were far apart in our sample. We did not investigate the reason, and a single conversation cannot tell you how often that happens. Build the page so it reads well either way: show replyCount on the root as X reports it, render the replies you received, and link to the original post for the full view.
Cache threads briefly. A live thread changes faster than a profile, so the route uses revalidate: 30 and caps each view at 5 pages.
// app/api/thread/route.ts - rebuild a reply tree with conversation search
import { type NextRequest } from "next/server";
import { toPost, type Post } from "@/lib/post";
const BASE = "https://api.twitterapi.io";
export async function GET(request: NextRequest) {
const id = request.nextUrl.searchParams.get("id") ?? "";
if (!/^[0-9]{5,25}$/.test(id)) return Response.json({ error: "bad id" }, { status: 400 });
const replies: Post[] = [];
let cursor = "";
for (let page = 0; page < 5; page++) { // cap pages per thread view
const url = new URL(`${BASE}/twitter/tweet/advanced_search`);
url.searchParams.set("query", `conversation_id:${id}`);
url.searchParams.set("queryType", "Latest");
url.searchParams.set("cursor", cursor);
const res = await fetch(url, {
headers: { "X-API-Key": process.env.TWITTERAPI_IO_API_KEY! },
next: { revalidate: 30 },
});
const body = await res.json();
replies.push(...(body.tweets ?? []).map((t: any) => toPost(t)));
if (!body.has_next_page || !body.next_cursor) break;
cursor = body.next_cursor;
}
// Group by parent so the page can render nested replies under the right post.
const children: Record<string, Post[]> = {};
for (const r of replies) {
const parent = r.inReplyToId ?? id;
(children[parent] ??= []).push(r);
}
for (const list of Object.values(children)) {
list.sort((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt));
}
return Response.json({ rootId: id, count: replies.length, children });
}What real posts look like: the post card checklist
A clone's post card is where seed data hides problems. In 960 real posts from six organization accounts, these were the shares of posts carrying each element. Design the card for all of them before you style it.
Long posts are common. 124 of the 729 original posts (17.0%) had more than 280 characters in the text field as returned (median 210, p95 324, max 1,211). X's standard limit for a post is 280 characters (X Help Center, help.x.com/en/using-x/how-to-post), and longer posts are available on some accounts, so the card needs a "Show more" fold rather than a fixed-height text box. Count characters on the rendered text, not on raw bytes, because emoji and t.co links change the length.
Reposts change the header. 24.1% of the feed were reposts. Render the reposting account as a small label and the original author in the card header, and read counts from the inner post, which is what readers expect.
Articles exist too. 1.6% of posts carried an article object (long-form X articles). A simple clone can show the title and link out.

Caching and cost: choose revalidate times from real posting rates
Every refresh of a feed page that returns 20 posts is billed for 20 posts: 15 credits each, $0.15 per 1,000 posts, so $0.003 per full page. Profiles are $0.18 per 1,000. A request that returns nothing still costs the 15-credit minimum ($0.00015). The cache time on each route therefore sets the upper bound on what one busy page can cost per day, no matter how many visitors arrive.
The posting rates we measured favor longer cache times. Over each account's newest 20 posts, NASA posted 2.67 times a day, supabase 1.9, github 1.58, vercel 0.67, nextjs 0.2 and reactjs 0.05. Even the busiest of the six would show a new post on fewer than one in fifty 10-minute refreshes, so a 60-second cache buys almost nothing for organization timelines like these. Measure your own accounts before you pick a number.
Compared with the official X API. X's pay-per-usage rate card (docs.x.com/x-api/getting-started/pricing) lists $0.005 per post read and $0.010 per user read, with post reads capped at 3 million per monthly billing cycle on pay-per-usage plans. A page of 20 posts is $0.10 there versus $0.003 here, about 33x more per 1,000 posts ($5 versus $0.15). X also offers $20 in free credits after a first card purchase. Reads through twitterapi.io need no X account or developer app; new accounts get free starter credits (no card, one per person or network, expiring after 31 days) and the amount is on the pricing page.
Rate limits. Accounts run at 0.2 requests a second before the first payment and 20 a second once paid (50 on Scale, 500 on Business). With route-level caching, a clone's upstream traffic stays far below that even with many visitors, because visitors hit your cache, not the API.

How we collected this
Question. What does real X timeline data look like when it is loaded into a Twitter-style clone instead of seed data: page size, which elements a post card must render, how long posts get, how fast timelines move, and how deep a reply tree goes?
Accounts and query. Six public organization accounts (vercel, nextjs, reactjs, github, supabase, NASA), 8 pages of /twitter/user/last_tweets each with replies excluded (the default), 960 posts in total. One conversation: the vercel post with the highest replyCount among the recent posts in the sample, rebuilt with /twitter/tweet/advanced_search and conversation_id:<id>, plus one comparison call to /twitter/tweet/replies, which returned 20 replies before its cursor ended.
Window and size. The newest posts of each account at collection time, collected in 2026; per-account windows ran from 57.3 days (supabase) to 1,854.9 days (reactjs). 53 read requests, about $0.15 at list price. Payload size is the compact UTF-8 JSON of each page body; the slim size uses the Post mapping on this page.
What the sample cannot show. Six organization accounts are not a random sample of X: personal accounts post with different media mixes, lengths and rates. Text length counts characters in the text field as returned, which is not the same as X's weighted character count. One conversation shows that a gap between replyCount and returned replies can happen, not how often or why. We did not measure latency, because our shared, rate-limited collection client spaces requests on purpose.
Privacy. Aggregates only. Organization accounts are named; reply authors in the conversation are counted, never named, quoted or linked, and their raw pages were not kept. The de-identified per-post sample (account, year, length, element flags, counts) is in the study folder with the analysis and chart scripts.
"""clone_fixture.py - pull real X data for a Twitter-style clone and write it as typed JSON
fixtures (feed, profile, thread) that a Next.js or React app can load in development.
pip install requests
export TWITTERAPI_IO_API_KEY=... # from the twitterapi.io dashboard
python clone_fixture.py vercel
"""
import json
import os
import sys
import time
import requests
BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_IO_API_KEY"]}
PAUSE = 0.5 # fixed pacing between calls
def get(url, params):
r = requests.get(url, headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
body = r.json()
if body.get("status") == "error":
raise SystemExit(f"API error: {body.get('msg')}")
time.sleep(PAUSE)
return body
def to_post(t, depth=0):
a = t.get("author") or {}
media = (t.get("extendedEntities") or {}).get("media") or []
return {
"id": t["id"],
"text": t.get("text", ""),
"createdAt": t.get("createdAt"),
"likeCount": t.get("likeCount", 0),
"retweetCount": t.get("retweetCount", 0),
"replyCount": t.get("replyCount", 0),
"viewCount": t.get("viewCount"),
"author": {"userName": a.get("userName"), "name": a.get("name"),
"avatar": a.get("profilePicture"), "isBlueVerified": bool(a.get("isBlueVerified"))},
"media": [{"type": m.get("type"), "url": m.get("media_url_https")} for m in media],
"repostOf": to_post(t["retweeted_tweet"], 1) if t.get("retweeted_tweet") and depth == 0 else None,
"quoted": to_post(t["quoted_tweet"], 1) if t.get("quoted_tweet") and depth == 0 else None,
"inReplyToId": t.get("inReplyToId"),
"conversationId": t.get("conversationId"),
}
def feed(user, pages=3):
posts, cursor = [], ""
for _ in range(pages):
body = get(f"{BASE}/twitter/user/last_tweets", {"userName": user, "cursor": cursor})
posts += [to_post(t) for t in body["data"]["tweets"]]
if not body.get("has_next_page") or not body.get("next_cursor"):
break
cursor = body["next_cursor"]
seen, unique = set(), []
for p in posts: # dedupe by id across pages
if p["id"] not in seen:
seen.add(p["id"])
unique.append(p)
return unique
def profile(user):
d = get(f"{BASE}/twitter/user/info", {"userName": user})["data"]
keep = ["id", "name", "userName", "description", "location", "followers", "following",
"statusesCount", "createdAt", "isBlueVerified", "profilePicture", "coverPicture"]
return {k: d.get(k) for k in keep}
def thread(root_id, pages=3):
replies, cursor = [], ""
for _ in range(pages):
body = get(f"{BASE}/twitter/tweet/advanced_search",
{"query": f"conversation_id:{root_id}", "queryType": "Latest", "cursor": cursor})
replies += [to_post(t) for t in body.get("tweets", [])]
if not body.get("has_next_page") or not body.get("next_cursor"):
break
cursor = body["next_cursor"]
children = {}
for r in replies:
children.setdefault(r["inReplyToId"] or root_id, []).append(r)
return {"rootId": root_id, "count": len(replies), "children": children}
if __name__ == "__main__":
user = sys.argv[1] if len(sys.argv) > 1 else "vercel"
posts = feed(user)
busiest = max(posts, key=lambda p: p["replyCount"]) if posts else None
out = {
"profile": profile(user),
"feed": posts,
"thread": thread(busiest["id"]) if busiest and busiest["replyCount"] else None,
}
with open(f"fixture-{user}.json", "w") as f:
json.dump(out, f, ensure_ascii=False, indent=1)
print(f"{len(posts)} posts, thread replies: {out['thread']['count'] if out['thread'] else 0}")
Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.
Questions readers ask
What is a Twitter clone?
A Twitter clone is a practice or product app that rebuilds the core screens of a microblog: a feed of short posts, profile pages, post pages with replies, and usually compose, like and follow. Developers build one to learn full-stack patterns (auth, feeds, pagination, caching). Give yours its own name and design; it should not use X's logo or present itself as X.
Can a Twitter clone show real tweets from X?
Yes, as read-only content. Server-side route handlers call /twitter/user/last_tweets, /twitter/user/info and /twitter/tweet/advanced_search with your API key and pass slim JSON to the page. Show the author name and handle with each post and link to the original. Posts written inside your app stay in your own database.
Which stack should I use for a Twitter clone?
Any React framework works. This guide uses Next.js App Router because route handlers keep the API key on the server and fetch with next: { revalidate } gives per-route caching. For your own users and posts, pick any database (Postgres with Prisma, Supabase, MongoDB, Firebase). For a mobile app, see the Flutter Twitter clone guide.
How do I paginate the feed like X does?
Use the cursor the API returns. Call /twitter/user/last_tweets with an empty cursor, render data.tweets, and while has_next_page is true pass next_cursor on the next call. Dedupe by id when appending, and drive it from a "Load more" button or an IntersectionObserver.
How do I build the replies section of a post page?
Search the conversation: /twitter/tweet/advanced_search with query=conversation_id:<root id> and queryType=Latest, paged with next_cursor. Group replies by inReplyToId to nest them. In our one-thread test, about a third of returned replies answered another reply, not the root.
How much does it cost to run a clone on real data?
Reads are $0.15 per 1,000 posts returned ($0.003 for a full page of 20) and $0.18 per 1,000 profiles, with a 15-credit ($0.00015) minimum per request. With a 10-minute cache, one busy timeline costs no more than $0.432 a day however many visitors you have. The official X API lists $0.005 per post read, about 33x more per 1,000 posts.
Can my clone post to X or like posts?
Only through an authenticated session for an account you control: one /twitter/user_login_v2 login ($0.10, with a proxy you supply) returns login_cookies, and calls such as /twitter/create_tweet_v2 then cost 60 credits ($0.0006) per successful call; calls that return status: error are not charged. Each call acts as that account, so keep a normal human pace; X's automation rules apply and the account can be rate-limited, locked or suspended, and the session can need a re-login. For a learning clone, keep compose inside your own database.
Continue
- Next.js docs: route.js (Route Handlers, GET caching default changed in v15, params as a promise)
- Next.js docs: fetch options (next.revalidate cache lifetime, opt-in caching)
- twitterapi.io docs: Get User Last Tweets (20 per page, cursor, includeReplies, pin_tweet)
- twitterapi.io docs: Advanced Search (query, queryType, cursor, response fields)
- X developer docs: pay-per-usage pricing (post read, user read, 3M monthly cap)
- X Help Center: how to post (280-character standard limit)
- X (Twitter) API overview and endpoints
- Build a Twitter clone in Flutter and Dart
- Embed and render tweets in React
- Get a user timeline with the X API
- Twitter conversation ID and reply threads
- Twitter feed API for websites and apps
- TwitterAPI.io pricing and free starter credits
- 01B2B on Twitter (X) in 2026: Is It Worth It, and What Actually Works
- 02Twitter (X) Lead Generation: Finding and Qualifying Buyers with Search
- 03Twitter (X) Influencer Marketing: Find and Vet Creators With Data
- 04Twitter (X) and MongoDB: store tweets as documents, upsert by id, query them fast
- 05Supabase + Twitter (X) API: store tweets in Postgres with an Edge Function and pg_cron
- 06Flutter Twitter (X) Clone: Render Real Tweets in a Dart App
- 07How to Audit a Twitter (X) Account for Fake Followers and Engagement Health
- 08Twitter (X) Lists API — Programmatic Guide
Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.
Stop reading. Start building.
Starter credits cover real testing on real data. Google sign-in, no card, no application queue.
Get an API keyAlready building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.