X (Twitter) user tweets, next page (beta)
The page of an account’s posts after a previous one: pass the same handle and that page’s meta.next_token as after. Beta: X changes this part of its site more often than the others.
GET /v1/x/users/{username}/tweets/nextBeta2 credits per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/x/users/NASA/tweets/next?after=DAAHCgABHX2KIIQ__-wLAAIAAAATMjEyMzA5Mjk3MjI5NjE2MzQ0MwgAAwAAAAIAAA",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 2 credits{ "data": [ { "id": "2123520987698270687", "text": "On Sunday, Nov. 29, our @NorthropGrumman cargo mission is scheduled to lift off …", "created_at": "2026-11-19T20:57:11.000Z", "author_id": "11348282", "conversation_id": "2123520987698270687", "lang": "en", "possibly_sensitive": false, "edit_history_tweet_ids": [ "2123520987698270687" ], "public_metrics": { "like_count": 1403, "retweet_count": 193, "reply_count": 106, "quote_count": 13, "bookmark_count": 60, "impression_count": 342862 }, "entities": { "urls": [ "…" ], "mentions": [ "…" ] }, "…": "1 more fields" }, "… 19 more" ], "includes": { "users": [ { "id": "11348282", "name": "NASA", "username": "NASA", "created_at": "2007-12-19T20:20:32.000Z", "description": "Making the seemingly impossible, possible. ✨", "location": "Pale Blue Dot", "url": "https://t.co/9NkQJKAnuU", "profile_image_url": "https://pbs.twimg.com/profile_images/1321163587679784960/0ZxKlEKB_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/11348282/1788992290", "protected": false, "…": "4 more fields" }, "… 9 more" ], "tweets": [ { "id": "2123502343752986746", "text": "Oh, how you shined!\n\nTo everyone who raised a light or lit up a landmark to cele…", "created_at": "2026-11-19T19:43:06.000Z", "author_id": "15165493", "conversation_id": "2123502343752986746", "lang": "en", "possibly_sensitive": false, "edit_history_tweet_ids": [ "…" ], "public_metrics": { "…": "6 fields" }, "entities": { "…": "1 fields" }, "…": "1 more fields" }, "… 11 more" ], "media": [ { "media_key": "3_2123520984699297792", "type": "photo", "url": "https://pbs.twimg.com/media/HXhDFa4W4AAJZaF.jpg", "width": 1920, "height": 1279, "alt_text": "A photo of NASA’s Northrop Grumman Commercial Resupply Services 24 spacecraft as…" }, "… 19 more" ] }, "meta": { "result_count": 20, "newest_id": "2123520987698270687", "oldest_id": "2122777345777934683", "next_token": "4bsdtpcpxh9j1633", "view": "timeline" }}Parameters
| Name | Type | Description |
|---|---|---|
usernamepath · required | string | Handle, with or without the @, or a profile URL. Example: NASA. |
afterquery · required | string | Cursor: the previous page's meta.next_token (x_user_tweets or this endpoint). |
sincequery | string | Only posts on or after this time. Reaching an older post ends the walk: YYYY-MM-DD (UTC) or an ISO 8601 timestamp. Example: 2026-11-01. |
untilquery | string | Only posts on or before this time (a date includes that whole UTC day): YYYY-MM-DD (UTC) or an ISO 8601 timestamp. Example: 2026-11-01. |
stop_at_idquery | string | The newest post you already hold (id or URL): the page stops just before it and there is no next page. |
Response fields
200 with a XTimelineResponse, in the shape of X’s API v2 Tweet and User objects.
| Field | Type | Description |
|---|---|---|
data | XTweet[] | |
includes | XIncludes | Objects the response refers to by id, each once: authors, quoted and reposted posts, media, polls. |
meta | XTimelineMeta |
Status codes
| Status | Meaning |
|---|---|
200 | The next page of posts. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The post or account does not exist, was deleted, or is suspended. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | X is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
What does beta mean here?
A page can occasionally fail while X changes its site. A failed page is never charged; retry it, or start again from the latest posts if the token has expired.
How long does a token last?
An hour. After that, fetch the latest posts again and page from there.
X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.