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 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://www.teapawt.net/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": "…"}
}

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=top is 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:

NameAdds
entitiesMentions, hashtags, symbols, and links, each with where it sits in the text. A link has its full url.
cardLink preview: title, description, image.
pollChoices, votes, and end time.
sourceClient the post was sent from.
locationPlace name on the post.
noteCommunity note text.
historyEdit-history ids, when there is more than one.
variantsEvery video format. Implies media.
labelsPaid promotion and AI-generated flags.
replyreply_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://www.teapawt.net/api/search?q=rust&tweet.fields=created_at,author,metrics&user.fields=verified,followers

Errors

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." }] }
CodeStatusWhen
pass_required401No paid pass on this request, or an API key that was not accepted: mistyped, revoked, or on a pass that has run out.
invalid400A missing or malformed parameter, an unknown field, or a bad username or id.
blocked400X will not run that search.
not_found404No such account or post.
suspended403The account is suspended.
protected403The account's posts are private.
rate_limited429The accounts are out of calls, or this address is calling faster than its budget refills. Retry-After says how many seconds to wait.
unavailable503X returned nothing for this call. Try it again.
error500The call failed on this side.