API documentation
A REST API for public X data: profiles, tweets, search, followers, lists and trends. Every endpoint is a GET, returns JSON, and costs a fixed number of tokens shown below. New accounts get 1,000 tokens once their email is confirmed.
Quickstart
- Create an account and confirm your email.
- Create your API key on the API key page. It is shown once, so store it somewhere safe.
- Send it in the x-api-key header:
curl "https://api.xscraper.online/api/v1/twitter/users/profile_by_username/jack" \
-H "x-api-key: $XSCRAPER_KEY"Authentication
Every request needs x-api-key: <your key>. Keys start with xs_. Each account has one key; rotating it issues a new one and stops the old one at once. Keep the key on your server. Do not ship it in browser or mobile code.
Tokens and pricing
Each call costs its endpoint's price. Endpoints that take count charge a base price plus a price per page of results, so asking for more costs more. The price is charged only when the call succeeds: any error response is refunded, except 404 (not found), which is a real answer and is charged. Every response reports x-tokens-cost and x-tokens-remaining.
| Endpoint | Path | Min | Max |
|---|---|---|---|
| Tweets | |||
| User tweets | 3 | 7 | |
| Latest tweet | 1 | 1 | |
| User tweets and replies | 3 | 7 | |
| User tweets by ID | 3 | 7 | |
| User tweets and replies by ID | 3 | 7 | |
| Liked tweets | 4 | 8 | |
| Tweet by ID | 1 | 1 | |
| Tweet replies | 4 | 4 | |
| Tweet quotes | 4 | 4 | |
| Search | |||
| Search profiles | 4 | 6 | |
| Search tweets | 6 | 14 | |
| Advanced search | 8 | 12 | |
| Profiles | |||
| Profile by username | 1 | 1 | |
| Profile by user ID | 3 | 3 | |
| Username to user ID | 1 | 1 | |
| Social graph | |||
| Followers | 4 | 4 | |
| Following | 4 | 4 | |
| Lists | |||
| List tweets | 3 | 7 | |
| Trends | |||
| Trends | 2 | 2 | |
Responses
Every response, success or error, uses the same envelope. The payload is in data.
{
"success": true,
"message": "Profile for @jack",
"data": {
"userId": "12",
"username": "jack"
},
"errors": null
}{
"success": false,
"message": "Not enough tokens: this call costs 14 and your balance is 10.",
"data": null,
"errors": [
{
"field": "balance",
"message": "insufficient_tokens"
}
]
}Errors
| Status | Meaning |
|---|---|
| 400 | A parameter is missing or invalid. The message says which. |
| 401 | Missing, unknown or revoked x-api-key. |
| 402 | Your balance is lower than the call's price. Nothing was charged. |
| 403 | The endpoint needs an admin key. |
| 404 | The user, tweet or list does not exist or is not visible. Charged: the lookup ran. |
| 429 | More than 100 requests in a minute on one key. Wait for Retry-After seconds. |
| 503 | The scraper pool is busy. Retry after the Retry-After header. |
| 5xx | Upstream failure. Safe to retry. |
Rate limits
Each key can make 100 requests per minute. Responses carry X-RateLimit-Limit and X-RateLimit-Remaining; a 429 also carries Retry-After. Rate limited calls are not charged.
All endpoints
The same list is available as an OpenAPI 3.1 spec at /openapi.json and as a plain-text summary for AI agents at /llms.txt.
- Profile by username1 tokenFull public profile: bio, counts, avatar, banner, verification.Reference
- Profile by user ID3 tokensProfile for a numeric user ID. Resolves the username first, up to 4 upstream calls.Reference
- Username to user ID1 tokenResolve a screen name to its numeric user ID.Reference
- Search profiles4–6 tokensFind accounts matching a query, with cursor pagination.Reference
- User tweets3–7 tokensMost recent tweets from a user, newest first.Reference
- Latest tweet1 tokenThe single most recent tweet from a user.Reference
- User tweets and replies3–7 tokensTweets and replies from a user, newest first.Reference
- User tweets by ID3–7 tokensMost recent tweets for a numeric user ID.Reference
- User tweets and replies by ID3–7 tokensTweets and replies for a numeric user ID.Reference
- Liked tweets4–8 tokensTweets a user liked, with cursor pagination.Reference
- Tweet by ID1 tokenA single tweet with media, counts and author.Reference
- Tweet replies4 tokensReplies in a tweet's conversation, 20 per page.Reference
- Tweet quotes4 tokensQuote tweets of a tweet, 20 per page.Reference
- Search tweets6–14 tokensSearch tweets with X search operators. Returns up to
countresults.Reference - Advanced search8–12 tokensSearch tweets page by page. Pass
nextback ascursorfor the next page.Reference - Followers4 tokensAccounts following a user, up to 50 per page. Pass
nextback ascursorfor more.Reference - Following4 tokensAccounts a user follows, up to 50 per page. Pass
nextback ascursorfor more.Reference - List tweets3–7 tokensTweets from a list timeline, with cursor pagination.Reference
- Trends2 tokensCurrent trending topics.Reference