X (Twitter) Community posts API
The top or media posts of an X Community, as X shows them to a logged-out visitor, in X API v2 shapes with authors and media in includes.
GET /v1/x/communities/{id}/tweets1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/x/communities/1926186499399139650/tweets",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "data": [ { "id": "2116378414223589764", "text": "racing to 200 \nlet's connect if you're into tech! https://t.co/80v46PiRNB", "created_at": "2026-10-31T03:55:09.000Z", "author_id": "1760564452284362752", "conversation_id": "2116378414223589764", "lang": "en", "possibly_sensitive": false, "edit_history_tweet_ids": [ "2116378414223589764" ], "public_metrics": { "like_count": 5, "retweet_count": 0, "reply_count": 4, "quote_count": 0, "bookmark_count": 0, "impression_count": 159 }, "entities": { "urls": [ "…" ] }, "…": "1 more fields" }, "… 7 more" ], "includes": { "users": [ { "id": "1760564452284362752", "name": "Laksh Nijhawan", "username": "laksh_2705", "created_at": "2024-02-22T07:18:13.000Z", "description": "21 • product engineer @byro_ai • ex @timesofindia", "location": "New Delhi", "url": "https://t.co/TzNORXFrr7", "profile_image_url": "https://pbs.twimg.com/profile_images/2114974413833777152/cdhblKZq_normal.jpg", "profile_banner_url": "https://pbs.twimg.com/profile_banners/1760564452284362752/1793084455", "protected": false, "…": "5 more fields" }, "… 3 more" ], "media": [ { "media_key": "3_2116378343662911488", "type": "photo", "url": "https://pbs.twimg.com/media/HV7i4_hbgAAVblu.png", "width": 447, "height": 169 }, "… 3 more" ] }, "meta": { "result_count": 8, "newest_id": "2122259975313486029", "oldest_id": "2116378414223589764" }}Parameters
| Name | Type | Description |
|---|---|---|
idpath · required | string | A community id or URL. Example: 1926186499399139650. |
viewquery | "top" | "media" | top (default) or media. One of top, media. |
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. |
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 community’s 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
Why only one page?
X shows a logged-out visitor one page of a community’s posts; further pages and the newest-first tab need a login.
X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.