The Twitter (X) API over x402: pay per call, no API key
An agent or script can read public X data from twitterapi.io without an account: it sends the request, gets an HTTP 402 with a price, pays that price in USDC on Base or Solana, and gets the data back. Each call is paid on its own, starting at $0.005.
read-only routes: tweets, users, lists, communities, Spaces, trends
lowest price per call (a profile, an article, a Space)
USDC on Base or on Solana, your client picks
How one paid call works
- 1Send the normal GET request to an
/x402/twitter/…route with no key and no payment. - 2We answer
402 Payment Requiredwith aPAYMENT-REQUIREDheader: base64 JSON with the price, the accepted networks and the address to pay. - 3Your x402 client signs a USDC payment for that exact amount and sends the same request again with it in the
PAYMENT-SIGNATUREheader. - 4The payment is checked, the data is fetched, and you get
200with the same JSON body as the regular endpoint.
# Step 1: ask for the price (no payment, nothing is charged)
curl -i "https://api.twitterapi.io/x402/twitter/user/info?userName=jack"
# HTTP/2 402
# payment-required: eyJ4NDAyVmVyc2lvbiI6Mi... (base64 JSON)
# {"error":"Payment required"}The 402 offer for a profile lookup, decoded
This is what the header of /x402/twitter/user/info said when we requested it in 2026. There are two entries in accepts, one per chain; your client signs one of them.
| Field | Base | Solana | What it means |
|---|---|---|---|
| scheme | exact | exact | a fixed price, not metered |
| network | eip155:8453 | solana:5eykt4Us… | Base mainnet / Solana mainnet (CAIP-2 IDs) |
| amount | 5000 | 5000 | USDC has 6 decimals, so 5000 = $0.005 |
| asset | 0x833589fC… | EPjFWdd5… | the USDC token contract on each chain |
| payTo | our address | our address | where the USDC goes |
| maxTimeoutSeconds | 300 | 300 | the signed payment is valid for 5 minutes |
New to the protocol itself? Our x402 protocol explainer covers who settles the payments, the v2 spec and how x402 compares with other agent payment schemes.
Call it from TypeScript
Any x402 v2 client handles steps 1 to 4. With the @x402/fetch package from the x402 project, a paid search is one wrapped fetch:
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch"
import { ExactEvmScheme } from "@x402/evm"
import { privateKeyToAccount } from "viem/accounts"
// A wallet holding a little USDC on Base. Keep the key in an env var.
const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`)
const payFetch = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
})
// Reads the 402 offer, signs $0.006 in USDC, retries, returns the data.
const res = await payFetch(
"https://api.twitterapi.io/x402/twitter/tweet/advanced_search" +
"?query=" + encodeURIComponent("x402 -is:retweet") + "&queryType=Latest",
)
const page = await res.json()
console.log(page.tweets.length, "posts, next cursor:", page.next_cursor)For Solana, register the Solana scheme client from the same project instead of the EVM one. The response body matches the regular endpoint, so code written against our x402 docs or the API reference works unchanged.
All 33 routes and what one call costs
Every route is a GET under https://api.twitterapi.io/x402/twitter. Paginated routes return one page per call; pass the cursor from the response to get the next page, which is a new paid call. Agents can read the same list as JSON at /.well-known/x402 or in the OpenAPI file.
| Route | One call returns | Price |
|---|---|---|
| Tweets | ||
| /tweet/advanced_search | 1 page, up to 20 posts | $0.006 |
| /tweets | up to 20 posts by ID | $0.006 |
| /tweet/replies | up to 20 replies | $0.006 |
| /tweet/replies/v2 | 1 large page, up to about 140 replies | $0.042 |
| /tweet/quotes | up to 20 quote posts | $0.006 |
| /tweet/retweeters | up to 20 users | $0.006 |
| /tweet/thread_context | the thread around a post | $0.018 |
| /article | 1 X Article, full text | $0.005 |
| Users | ||
| /user/info | 1 profile | $0.005 |
| /user/batch_info_by_ids | up to 20 profiles by ID | $0.008 |
| /user_about | 1 'About this account' record | $0.005 |
| /user/search | up to 20 accounts | $0.008 |
| /user/last_tweets | 1 page, about 20 posts | $0.015 |
| /user/tweet_timeline | 1 page of a timeline | $0.018 |
| /user/mentions | up to 20 posts | $0.006 |
| /user/articles | 1 page of X Articles | $0.005 |
| /user/followers | up to 200 followers | $0.008 |
| /user/followings | up to 200 accounts | $0.008 |
| /user/verifiedFollowers | up to 20 verified followers | $0.005 |
| /user/followers_ids | up to 5,000 follower IDs | $0.08 |
| /user/subscriptions | up to 20 accounts | $0.006 |
| /user/check_follow_relationship | follows / followed-by for 2 users | $0.005 |
| Lists, communities, Spaces, trends | ||
| /list/tweets | up to 20 posts | $0.006 |
| /list/tweets_timeline | up to 100 posts | $0.03 |
| /list/followers | up to 20 users | $0.008 |
| /list/members | up to 20 users | $0.008 |
| /community/info | 1 community | $0.005 |
| /community/members | up to 20 users | $0.008 |
| /community/moderators | up to 20 users | $0.008 |
| /community/tweets | up to 20 posts | $0.006 |
| /community/get_tweets_from_all_community | 1 page of community posts | $0.009 |
| /spaces/detail | 1 Space | $0.005 |
| /trends | up to 50 trends for a location | $0.015 |
x402, an API key or the official X API?
x402 trades price for zero setup. The same reads with a prepaid twitterapi.io API key cost much less per call, and both are below the official X API's pay-per-use rates for these two reads:
| Task | x402 (no account) | twitterapi.io API key | Official X API |
|---|---|---|---|
| Look up 1 profile | $0.005 | $0.00018 | $0.010 |
| Search: 1 page of 20 posts | $0.006 | $0.003 | $0.10 |
API key prices are $0.18 per 1,000 profiles and $0.15 per 1,000 posts (see pricing). Official X prices are $0.010 per user read and $0.005 per post read, from X's X API pricing page, checked in 2026; that route also needs an X developer account and app.
Use x402 when
an agent needs a few reads without anyone signing up, you want to pay from a wallet instead of a card, or each call is billed on to someone else.
Use an API key when
you read every day or in volume, you need the stream or write actions, or you want the lowest price per call. Measured response times are on the latency benchmarks page.
When a call is and isn't charged
- Not charged: the payment completes only after the data request succeeds. A
400for a missing or invalid parameter (for example more than 20 IDs), or a failed data request, costs nothing. - Charged: a successful call that returns no results, and a lookup where some IDs are deleted or not found (they are left out of the result).
- One use per payment: sending the same signed payment again returns
402withPayment already used.
Where our x402 routes are listed
If your agent finds paid APIs through an x402 directory, these are the places our routes appear:
- x402scan
An explorer for x402 servers and payments. All 33 of our routes are registered there.
twitterapi.io on x402scan - PayAPI Market
A marketplace of paid API routes. Two of ours are listed and verified: user profile lookup and advanced search.
User profile route on PayAPI Market - Coinbase x402 Bazaar
The discovery catalog in Coinbase's x402 stack. Agents that query it can find our routes by our pay-to address; there is no per-merchant page to link to.
How the Bazaar discovery works
The second PayAPI Market listing is advanced search on PayAPI Market.
Reading every day? Use a key.
An API key covers the same data at a lower price per call, plus the stream and write actions. Agents that speak MCP can use our hosted Twitter MCP server with that key.
Get your API key