Get the replies to an X post with Python, Node.js and cURL

Read the replies under one X post, most liked first. The id is the digits after /status/ in a post's link; this one is a NASA post with 374 replies.

It is one call to GET /v1/x/posts/{id}/replies, 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/2113776971603689874/replies",
    headers={"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
    params={"sort": "likes", "limit": 5},
    timeout=60,
)
response.raise_for_status()
page = response.json()

for reply in page["data"]:
    print(reply["likeCount"], reply["text"][:60])
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/2113776971603689874/replies?sort=likes&limit=5",
  {
    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 reply of page.data) console.log(reply.likeCount, reply.text.slice(0, 60));
console.log("credits charged:", response.headers.get("x-credits-charged"));

cURL

curl --request GET \
  --url 'https://api.weirapp.io/v1/x/posts/2113776971603689874/replies?sort=likes&limit=5' \
  --header "Authorization: Bearer $WEIR_API_KEY"

Output

20 @NASA Moon or bust! https://t.co/5s1tZN0UHo
11 @NASA The Earth-orbit dress rehearsal isn't new. Apollo 9 te
9 @NASA 🫡 https://t.co/jeJnU62fpO
7 @NASA Artemis III is the dress rehearsal before the Moon pre
7 @NASA https://t.co/C21R8hY7km
credits charged: 6

The next page

A page ends with meta.nextCursor. Send it back as cursor, with every other parameter unchanged, until it is null. Each page is its own request and is charged as one.

import os

import requests

headers = {"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"}
cursor = None
for number in range(1, 3):  # two pages; each page is its own charged request
    response = requests.get(
        "https://api.weirapp.io/v1/x/posts/2113776971603689874/replies",
        headers=headers,
        params={"sort": "likes", "limit": 5, **({"cursor": cursor} if cursor else {})},
        timeout=60,
    )
    response.raise_for_status()
    page = response.json()
    print(f"page {number}: {len(page['data'])} replies, {response.headers['X-Credits-Charged']} credits")
    cursor = page["meta"]["nextCursor"]
    if not cursor:  # null means there is nothing more
        break
page 1: 5 replies, 6 credits
page 2: 5 replies, 6 credits

If 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.

View this page as Markdown