X (Twitter) highlights API
The posts an X account has added to its Highlights tab, paginated with after.
GET /v1/x/users/{username}/highlights1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/x/users/levelsio/highlights",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "data": [ { "id": "2125944241042186601", "text": "🌏 My coworking day in 🇸🇬 Singapore is on!\n\nNext Monday on 30 November we'll meet…", "created_at": "2026-11-26T13:26:19.000Z", "author_id": "1577241403", "conversation_id": "2125944241042186601", "lang": "en", "possibly_sensitive": false, "edit_history_tweet_ids": [ "2125943976645808406", "… 1 more" ], "public_metrics": { "like_count": 151, "retweet_count": 5, "reply_count": 45, "quote_count": 1, "bookmark_count": 29, "impression_count": 22915 }, "entities": { "urls": [ "…" ], "mentions": [ "…" ] }, "…": "2 more fields" }, "… 18 more" ], "includes": { "users": [ { "id": "1577241403", "name": "@levelsio", "username": "levelsio", "created_at": "2013-07-08T09:31:59.000Z", "description": "💸https://t.co/sQ0aiU7v02\n📸https://t.co/lAyoqmSBRX $68K/m\n🎮https://t.co/tF49atJ39…", "location": "📕My book $4K/m 👉", "url": "https://t.co/6RM0RsUXfe", "profile_image_url": "https://pbs.twimg.com/profile_images/2077111020305162240/PwddgOau_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/1577241403/1665964220", "protected": false, "…": "5 more fields" }, "… 7 more" ], "tweets": [ { "id": "2122003192708018240", "text": "🌎 My Weekly Founder's Coworking Day is going global!\n\nI'll be in 🇸🇬 Singapore an…", "created_at": "2026-11-15T16:26:00.000Z", "author_id": "1577241403", "conversation_id": "2122003192708018240", "lang": "en", "possibly_sensitive": false, "edit_history_tweet_ids": [ "…" ], "public_metrics": { "…": "6 fields" }, "entities": { "…": "1 fields" }, "…": "2 more fields" }, "… 13 more" ], "media": [ { "media_key": "3_2125942827817508865", "type": "photo", "url": "https://pbs.twimg.com/media/HYDdvPjaIAEtDux.jpg", "width": 1024, "height": 1024 }, "… 21 more" ] }, "meta": { "result_count": 19, "newest_id": "2125944241042186601", "oldest_id": "2107055382459732293", "next_token": "3iqf1snntgyvd2qr" }}Parameters
| Name | Type | Description |
|---|---|---|
usernamepath · required | string | Handle, with or without the @, or a profile URL. Example: NASA. |
afterquery | string | Cursor: the previous page's meta.next_token. |
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 | Highlighted posts, with a next_token. |
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
Is it empty sometimes?
Yes, for accounts that highlight nothing.
X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.