100 free credits. No credit card required. Get a key

X (Twitter) user tweets API

An account’s latest posts and reposts, newest first (about 20), with the authors, quoted posts and media they refer to in includes. meta carries result_count, newest_id, oldest_id and a next_token for the next page.

GET /v1/x/users/{username}/tweets1 credit per callRefunded on failure
import os, requests

res = requests.get(
    "https://api.groundsocial.dev/v1/x/users/NASA/tweets",
    headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()
Response
200 · 1 credit
{
"data": [
{
"id": "2124940993489162256",
"text": "Happy Thanksgiving from the @Space_Station! https://t.co/MXpk17AAX6",
"created_at": "2026-11-23T18:59:46.000Z",
"author_id": "11348282",
"conversation_id": "2124940993489162256",
"lang": "en",
"possibly_sensitive": false,
"edit_history_tweet_ids": [
"2124940993489162256"
],
"public_metrics": {
"like_count": 1980,
"retweet_count": 268,
"reply_count": 84,
"quote_count": 15,
"bookmark_count": 90,
"impression_count": 340787
},
"entities": {
"urls": [
"…"
],
"mentions": [
"…"
]
},
"…": "1 more fields"
},
"… 18 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,
"…": "5 more fields"
},
"… 6 more"
],
"tweets": [
{
"id": "2124265863323045902",
"text": "A @SpaceX Dragon splashed down in the Pacific Ocean off the coast of California …",
"created_at": "2026-11-21T22:17:03.000Z",
"author_id": "1451773004",
"conversation_id": "2124265863323045902",
"lang": "en",
"possibly_sensitive": false,
"edit_history_tweet_ids": [
"…"
],
"public_metrics": {
"…": "6 fields"
},
"entities": {
"…": "2 fields"
},
"…": "1 more fields"
},
"… 6 more"
],
"media": [
{
"media_key": "13_2124940778208215040",
"type": "video",
"preview_image_url": "https://pbs.twimg.com/media/HX1OkiYWQAAGf8b.jpg",
"width": 720,
"height": 405,
"duration_ms": 165965,
"variants": [
"…"
]
},
"… 16 more"
]
},
"meta": {
"result_count": 19,
"newest_id": "2124940993489162256",
"oldest_id": "2123092972296163443",
"view": "timeline"
}
}

Parameters

NameTypeDescription
usernamepath · requiredstringHandle, with or without the @, or a profile URL. Example: NASA.
sincequerystringOnly 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.
untilquerystringOnly 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_idquerystringThe 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.

FieldTypeDescription
dataXTweet[]
includesXIncludesObjects the response refers to by id, each once: authors, quoted and reposted posts, media, polls.
metaXTimelineMeta
Status codes
StatusMeaning
200The latest posts, with what they refer to.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404The post or account does not exist, was deleted, or is suspended.
429Too many requests. Wait for Retry-After seconds.
503X is temporarily unavailable. Retryable; nothing was charged.

Every error has code, message, hint and retryable. All error codes

Questions

Why do I sometimes get only a few posts?

For some accounts X shows logged-out visitors only their latest few original posts, without reposts. Then meta.view is recent_originals and there is no next page.

How do I get older posts?

Pass meta.next_token as after to the next-page endpoint (beta, 2 credits a page). Tokens last an hour.

X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.