Get a whole X thread with Python, Node.js and cURL
Read a thread: the chain of posts an author wrote in reply to themselves, in order, from any post in it. This one is a NASA thread.
It is one call to GET /v1/x/posts/{id}/thread, which costs 1 credit a request, plus 1 per post. Every snippet below ran against the live API on 27 October 2026, and the output is what the Python printed.
Set your key first. Create one at https://weirapp.io/dashboard/keys; every account gets 5,000 free credits a month.
export WEIR_API_KEY=weir_live_...Python
import os
import requests
response = requests.get(
"https://api.weirapp.io/v1/x/posts/2112560726397092239/thread",
headers={"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
timeout=60,
)
response.raise_for_status()
page = response.json()
for post in page["data"]:
print(post["createdAt"], post["text"][:70].replace("\n", " "))
print("credits charged:", response.headers["X-Credits-Charged"])Node.js
// Node.js 18 or later, as an ES module (save as example.mjs).
const response = await fetch("https://api.weirapp.io/v1/x/posts/2112560726397092239/thread", {
headers: { Authorization: `Bearer ${process.env.WEIR_API_KEY}` },
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const page = await response.json();
for (const post of page.data)
console.log(post.createdAt, post.text.slice(0, 70).replaceAll("\n", " "));
console.log("credits charged:", response.headers.get("x-credits-charged"));cURL
curl --request GET \
--url 'https://api.weirapp.io/v1/x/posts/2112560726397092239/thread' \
--header "Authorization: Bearer $WEIR_API_KEY"Output
2026-10-20T15:05:00.000Z There's a lot of ground to cover when you're building a Moon Base. D
2026-10-20T15:05:01.000Z @NASAMoonBase The journey is just beginning. See how NASA and our part
credits charged: 3If a call fails
Failed calls are free. A 429 means too many requests a minute: wait the seconds in Retry-After and send it again. A 402 means the account is out of credits. A 503 means the source is busy and is safe to retry. Every code is on Errors, and paging is on Pagination.