X (Twitter) user profile API
A public X profile by handle: name, bio, location, website, join date, follower, following and post counts, checkmark type, and the pinned post in includes.tweets, shaped like X’s API v2 User object.
GET /v1/x/users/{username}1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/x/users/NASA",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "data": { "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, "verified": true, "verified_type": "government", "public_metrics": { "followers_count": 92130684, "following_count": 115, "tweet_count": 74576, "media_count": 28263 }, "pinned_tweet_id": "2124903027370774900", "entities": { "url": { "urls": [ { "start": 0, "end": 23, "url": "https://t.co/9NkQJKAnuU", "expanded_url": "http://www.nasa.gov/", "display_url": "nasa.gov" } ] } } }, "includes": { "tweets": [ { "id": "2124903027370774900", "text": "We're on our way to explore the mysteries of Europa, an ocean world that could support life.\n\nTake a behind-the-scenes l…", "created_at": "2026-11-23T16:28:55.000Z", "author_id": "11348282", "conversation_id": "2124903027370774900", "lang": "en", "possibly_sensitive": false, "edit_history_tweet_ids": [ "2124903027370774900" ], "public_metrics": { "like_count": 2684, "retweet_count": 423, "reply_count": 127, "quote_count": 53, "bookmark_count": 368, "impression_count": 407228 }, "entities": { "urls": [ { "…": "5 fields" }, { "…": "6 fields" } ] }, "attachments": { "media_keys": [ "7_2124902931874889728" ] } } ], "media": [ { "media_key": "7_2124902931874889728", "type": "video", "preview_image_url": "https://pbs.twimg.com/media/HX0sChTWkAAO3-x.png", "width": 720, "height": 405, "duration_ms": 87402, "variants": [ { "content_type": "application/x-mpegURL", "url": "https://video.twimg.com/amplify_video/2124902931874889728/pl/20P7_wOL27G5jRSc.m3u8?tag=16&v=bcb" }, { "bit_rate": 288000, "content_type": "video/mp4", "url": "https://video.twimg.com/amplify_video/2124902931874889728/vid/avc1/480x270/IzjJilP_7hefB9nh.mp4?tag=16" }, "… 3 more" ] } ] }}Parameters
| Name | Type | Description |
|---|---|---|
usernamepath · required | string | Handle, with or without the @, or a profile URL. Example: NASA. |
Response fields
200 with a XUserResponse, in the shape of X’s API v2 Tweet and User objects.
| Field | Type | Description |
|---|---|---|
data | XUser | |
includes | XIncludes | Objects the response refers to by id, each once: authors, quoted and reposted posts, media, polls. |
Status codes
| Status | Meaning |
|---|---|
200 | The profile and its pinned post. |
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
Can I pass @NASA or a profile URL?
Yes. A handle with or without the @, or the profile URL, all work.
Do you return private data?
No. Only what the public profile shows a logged-out visitor. Suspended and missing accounts answer 404 target_not_found, not charged.
X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.