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

X (Twitter) tweet API

One public post (tweet) by id or URL: text, author, like, repost, reply, quote, bookmark and view counts, media with video variants, quoted post and poll, shaped like X’s API v2 Tweet object. It also carries replies: the handful of top replies X shows a logged-out visitor.

GET /v1/x/tweets/{id}1 credit per callRefunded on failure
import os, requests

res = requests.get(
    "https://api.groundsocial.dev/v1/x/tweets/1585341984679469056",
    headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()
Response
200 · 1 credit
{
"data": {
"id": "1585341984679469056",
"text": "Entering Twitter HQ – let that sink in! https://t.co/D68z4K2wq7",
"created_at": "2022-10-26T18:45:58.000Z",
"author_id": "44196397",
"conversation_id": "1585341984679469056",
"lang": "en",
"possibly_sensitive": false,
"edit_history_tweet_ids": [
"1585341984679469056"
],
"public_metrics": {
"like_count": 1221661,
"retweet_count": 154511,
"reply_count": 58031,
"quote_count": 42891,
"bookmark_count": 14044
},
"entities": {
"urls": [
{
"…": "6 fields"
}
]
},
"…": "1 more fields"
},
"includes": {
"users": [
{
"id": "44196397",
"name": "Elon Musk",
"username": "elonmusk",
"description": "https://t.co/ZdBx5WABYx",
"profile_image_url": "https://pbs.twimg.com/profile_images/2122506092437504001/NSS4RHyZ_normal.jpg",
"protected": false,
"verified": true,
"verified_type": "blue",
"public_metrics": {
"…": "3 fields"
},
"entities": {
"…": "1 fields"
}
},
"… 1 more"
],
"media": [
{
"media_key": "7_1585341912877146112",
"type": "video",
"preview_image_url": "https://pbs.twimg.com/ext_tw_video_thumb/1585341912877146112/pu/img/DwJ7wlGIe9ir…",
"width": 1920,
"height": 1080,
"duration_ms": 9301,
"variants": [
"…"
]
}
]
},
"replies": [
{
"id": "1585385664606269440",
"text": "Meeting a lot of cool people at Twitter today!",
"created_at": "2022-10-26T21:39:32.000Z",
"author_id": "44196397",
"in_reply_to_user_id": "44196397",
"lang": "en",
"edit_history_tweet_ids": [
"1585385664606269440"
],
"public_metrics": {
"like_count": 257616,
"retweet_count": 10874,
"reply_count": 11381,
"quote_count": 1592,
"bookmark_count": 385
},
"referenced_tweets": [
{
"…": "2 fields"
}
]
},
"… 1 more"
]
}

Parameters

NameTypeDescription
idpath · requiredstringA post id or a post URL (x.com or twitter.com). Example: 1585341984679469056.
Response fields

200 with a XTweetResponse, 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.
repliesXTweet[]The top replies X shows a logged-out visitor under the post (usually a handful, ranked by X). Their authors and media are in includes. Not the full thread.
Status codes
StatusMeaning
200The post, what it refers to, and its top replies.
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

Can I pass a post URL?

Yes. The id can be the number at the end of the URL, or the URL itself (x.com or twitter.com).

Does it return every reply?

No. replies holds the few top replies X shows a logged-out visitor. The full, paginated replies endpoint is not switched on yet.

What about protected or deleted posts?

A post from a protected account answers 403 target_private; a deleted post or one from a suspended account answers 404 target_not_found. Neither is charged.

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