1 # X (Twitter)
2
3 Proxy requests to X (Twitter) via Replit-managed billing.
4
5 ## Callback
6
7 Use `externalApi__x` in `code_execution`.
8
9 ## Allowed operations
10
11 - `GET` `/2/(tweets|tweets/\d+|tweets/search/(?:recent|all)|tweets/\d+/quote_tweets|(?:lists|spaces)/[^/]+/tweets|users/[^/]+/(?:tweets|mentions)){/}?` - Posts: Read — every endpoint that returns Posts (search, lookup, user/list/space timelines, quote tweets). Billed per Post returned in `data`.
12 - `GET` `/2/(users|users/by|users/by/username/[^/]+|users/\d+|users/\d+/(?:affiliates|followers|following)|tweets/\d+/retweeted_by|lists/\d+/(?:followers|members)){/}?` - Users: Read — endpoints that return Users (multi/single lookup, retweeters, list followers/members, affiliates, followers, following). Billed per User returned in `data`.
13 - `GET` `/2/trends/by/woeid/:woeid(\d+){/}?` - Trend: Read — `GET /2/trends/by/woeid/{woeid}` returns trending topics for a Yahoo WOEID. Billed per Trend returned in `data`.
14 - `GET` `/2/(lists/\d+|users/\d+/(?:owned_lists|followed_lists|list_memberships)){/}?` - List: Read - reading public lists Billed per List returned in `data`.
15 - `GET` `/2/(spaces|spaces/by/creator_ids|spaces/search|spaces/[^/]+){/}?` - Space: Read — endpoints that return Spaces (multi-lookup, creator-id lookup, search, single lookup). Billed per Space returned in `data`.
16 - `GET` `/2/communities/:id(\d+){/}?` - Community: Read. Billed per Community returned in `data`.
17 - `GET` `/2/(tweets/counts/recent|news/search|news/\d{1,19}){/}?` - Counts: Recent — Post counts for last few days, news reads. All bill per HTTP request under X's shared Counts: Recent dashboard bucket.
18 - `GET` `/2/tweets/counts/all{/}?` - Counts: All — `GET /2/tweets/counts/all` returns per-bucket Post counts over the full archive. Billed per HTTP request, not per `data[]` bucket.
19
20 Authorization is handled automatically by Replit. Do not pass an `Authorization` header.
21
22 ## Skill
23
24 ## X (Twitter) quickstart
25
26 Read-only X API v2 access through passthrough billing. Use
27 concrete request paths (e.g. `/2/tweets/search/recent`) — never
28 send the route patterns literally. Put URL params in `query`.
29
30 ```javascript
31 const result = await externalApi__x({
32 path: '/2/tweets/search/recent',
33 method: 'GET',
34 query: {query: 'replit', max_results: '10'},
35 })
36
37 for (const tweet of result.body.data ?? []) {
38 console.log(tweet.id, tweet.text)
39 }
40 ```
41
42 Authorization is managed by passthrough billing. Do not set an
43 `Authorization` header manually.
44
45 ## Example
46
47 ```javascript
48 const result = await externalApi__x({
49 path: '/2/(tweets|tweets/\d+|tweets/search/(?:recent|all)|tweets/\d+/quote_tweets|(?:lists|spaces)/[^/]+/tweets|users/[^/]+/(?:tweets|mentions)){/}?',
50 method: 'GET',
51 query: {},
52 })
53
54 console.log(result.status)
55 console.log(result.body)
56 ```