API
Compact JSON for search, profiles, and posts. A page of results is the posts themselves, without the HTML chrome, so a client downloads much less than /search. The machine-readable description is OpenAPI. A search can also answer with X's own response, unchanged: see Raw search below.
A search pass is required. Get one, or sign in. A whitelisted address can call with no cookie.
Authentication
Create a key on the search pass page. It is 256 random bits, shown once. Send it on every call:
curl -sS --compressed \
-H 'Authorization: Bearer tpk_…' \
'https://teapawt.org/api/search?q=rust&f=latest&f-images=on'X-Api-Key: tpk_… is the same key. A signed-in browser can use the paid_search_pass cookie instead, and a whitelisted address needs neither. The same key skips the checkbox on /search and on search RSS. The five-minute search checkbox does not unlock this.
Responses are application/json and Cache-Control: private, no-store. Ask for gzip with Accept-Encoding and the body is compressed. Empty fields are left out. Post ids are strings, so they stay exact in JavaScript. Text is as X sends it: links are t.co links, and most posts arrive with &, < and > escaped.
Search
GET /api/search?q=QUERY — q is required (512 characters at most) unless from is set. f is latest (the default; tweets is the same), top, media, users, or lists. f=media keeps posts that have an image, video, GIF, poll image, or link-card image.
The search page's filters work here too. from, since (YYYY-MM-DD), until, and min_faves. Include toggles, value on (also true, 1, or yes): f-media, f-images, f-videos, f-native_video, f-links, f-news, f-quote, f-replies, f-spaces, f-verified, f-nativeretweets. Exclude toggles use e- and the same names (e-replies, e-nativeretweets, e-media, and the rest). A comma list does the same job: filters=images,links and exclude=replies. Operators inside q work as well, for example from:name since:2024-01-01 filter:images. Checking both include and exclude for one name keeps the exclude.
Pass meta.cursor back as cursor for the next page. It is left out when there is no further page. A page of posts can be empty and still have a cursor: every post on it was filtered out, and there are more behind it. Stop when the cursor is gone, or after two empty pages in a row. Searches run on the search-pass accounts.
{
"data": [{
"id": "20",
"text": "just setting up my twttr",
"created_at": "2006-03-21T20:50:14Z",
"lang": "en",
"author": {"id": "12", "username": "jack", "name": "jack"},
"metrics": {"reposts": 1, "likes": 2}
}],
"meta": {"result_count": 1, "cursor": "…"}
}Raw search
A client that already reads X's own JSON can have it. Add format=raw to GET /api/search and the answer is X's SearchTimeline response as it arrived: the same JSON, byte for byte, with nothing mapped, renamed, or left out. Without format, or with format=compact, a search answers in the compact format the rest of this page describes.
curl -sS --compressed \
-H 'Authorization: Bearer tpk_…' \
'https://teapawt.org/api/search?q=rust&f=latest&format=raw'q, f, the filters, and cursor work as they do above, on every tab. The results are under data.search_by_raw_query.search_timeline.timeline.instructions. The cursor for the next page is in there too: the cursor entry whose cursorType is Bottom holds it as value. On a later page X can send that entry in a TimelineReplaceEntry instruction instead of among the entries. Send the value back as cursor. It is the same token as meta.cursor, so one format can carry on from the other.
The last page carries a TimelineTerminateTimeline instruction whose direction is Bottom or TopAndBottom. It can come with the last results or on an empty page after them, so read that page and stop. Do not wait for the cursor to disappear or repeat: X usually sends one on the last page too, and it is a new token each time. If the instruction never comes, stop after two pages in a row with no results.
A first page, cut down to the parts named above:
{
"data": {"search_by_raw_query": {"search_timeline": {"timeline": {
"instructions": [{
"type": "TimelineAddEntries",
"entries": [
{
"entryId": "tweet-20",
"content": {"itemContent": {"tweet_results": {"result": {
"rest_id": "20",
"legacy": {"full_text": "just setting up my twttr", …},
…
}}}}
},
{
"entryId": "cursor-bottom-0",
"content": {"cursorType": "Bottom", "value": "…"}
}
]
}]
}}}}
}Nothing is taken out on the way. Promoted entries, X's own prompts, and every repost of one post arrive as X listed them, and f=media is X's Media tab as it is. tweet.fields and user.fields choose from the compact format, so a call that sends either with format=raw is refused as invalid. Fields about the viewer, such as favorited and following, describe the account the search ran on, not you.
The shape is X's, and X changes it without notice. A call that fails still answers in the error shape below, with a status that is not 200. When X could not fill one field of a page, its own errors array arrives beside data, under a 200. Only search has a raw format. The other calls answer in the compact format, with or without format.
Profiles and posts
Each path is the compact form of the X call named beside it. The same cursor, tweet.fields, and user.fields parameters apply.
GET /api/search— SearchTimeline.GET /api/lists/{id}/tweets— ListLatestTweetsTimeline.GET /api/communities/{id}/tweets?ranking=latest— CommunityTweetsTimeline.ranking=topis the relevance order.GET /api/users/{username}— UserByScreenName.GET /api/users/id/{id}— UserByRestId.GET /api/users/{username}/tweets— that account's posts.GET /api/users/{username}/with_replies— UserWithProfileTweetsAndRepliesQueryV2.GET /api/users/{username}/about— AboutAccountQuery.GET /api/users/{username}/following— Following.GET /api/users/{username}/following/ids?count=5000— 1.1/friends/ids. Ids only, up to 5000.GET /api/users/{username}/friends?count=200— 1.1/friends/list.GET /api/users/{username}/followers?count=200— 1.1/followers/list.GET /api/tweets/{id}— TweetDetail, as{ "data": { … } }.GET /api/tweets?ids=1,2,3— TweetResultsByRestIds, up to 100 ids.GET /api/tweets/{id}/retweeters— Retweeters.
A repost is the original post plus reposted_by and repost_id. A quote is nested once, without its own quote or video variant list. Missing metric counts are zero. protected and suspended are present only when true. The posts and the follow lists of a suspended or protected account answer 403. Media URLs point at the CDN. entities.start and entities.end count characters (Unicode code points, not bytes) into text.
Fields
Omit tweet.fields for the small default: created_at, lang, author, metrics, reply, media, quote, repost, sensitive. id and text are always included. Naming fields replaces that default, as on X's recent search. tweet.fields=all asks for every field.
Extra tweet fields:
| Name | Adds |
|---|---|
entities | Mentions, hashtags, symbols, and links, each with where it sits in the text. A link has its full url. |
card | Link preview: title, description, image. |
poll | Choices, votes, and end time. |
source | Client the post was sent from. |
location | Place name on the post. |
note | Community note text. |
history | Edit-history ids, when there is more than one. |
variants | Every video format. Implies media. |
labels | Paid promotion and AI-generated flags. |
reply | reply_to, in_reply_to_status_id, conversation_id. |
On a post, author is id, username, and name. user.fields adds verified, avatar, banner, bio, location, website, followers, following, posts, likes, media, joined, pinned, protected, suspended. user.fields=all selects those. A list of accounts (user search, following, followers, friends, retweeters) already includes verification, the avatar, the bio, counts, location, and website. GET /api/users/{username} returns the full profile.
https://teapawt.org/api/search?q=rust&tweet.fields=created_at,author,metrics&user.fields=verified,followersErrors
Every failure has the same shape, and it is JSON on every path listed above.
{ "errors": [{ "code": "pass_required", "message": "A search pass is required." }] }| Code | Status | When |
|---|---|---|
pass_required | 401 | No paid pass on this request, or an API key that was not accepted: mistyped, revoked, or on a pass that has run out. |
invalid | 400 | A missing or malformed parameter, an unknown field, or a bad username or id. |
blocked | 400 | X will not run that search. |
not_found | 404 | No such account or post. |
suspended | 403 | The account is suspended. |
protected | 403 | The account's posts are private. |
rate_limited | 429 | The accounts are out of calls, or this address is calling faster than its budget refills. Retry-After says how many seconds to wait. |
unavailable | 503 | X returned nothing for this call. Try it again. |
error | 500 | The call failed on this side. |