Skip to content
Browse the docs

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

  1. Create an account and confirm your email.
  2. Create your API key on the API key page. It is shown once, so store it somewhere safe.
  3. Send it in the x-api-key header:
Request
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.

EndpointMinMax
Tweets
User tweets/users/tweets/:username37
Latest tweet/users/latest_tweet/:username11
User tweets and replies/users/replies/:username37
User tweets by ID/users/tweets_by_user_id/:userId37
User tweets and replies by ID/users/replies_by_user_id/:userId37
Liked tweets/users/likes/:username48
Tweet by ID/tweets/:tweetId11
Tweet replies/tweets/:tweetId/replies44
Tweet quotes/tweets/:tweetId/quotes44
Search
Search profiles/users/search_profiles46
Search tweets/tweets/search614
Advanced search/tweets/advanced_search812
Profiles
Profile by username/users/profile_by_username/:username11
Profile by user ID/users/profile_by_userid/:userId33
Username to user ID/users/user_id/:username11
Social graph
Followers/users/followers/:userId44
Following/users/following/:userId44
Lists
List tweets/lists/:listId/tweets37
Trends
Trends/trends22

Responses

Every response, success or error, uses the same envelope. The payload is in data.

Success
{
  "success": true,
  "message": "Profile for @jack",
  "data": {
    "userId": "12",
    "username": "jack"
  },
  "errors": null
}
Error (402)
{
  "success": false,
  "message": "Not enough tokens: this call costs 14 and your balance is 10.",
  "data": null,
  "errors": [
    {
      "field": "balance",
      "message": "insufficient_tokens"
    }
  ]
}

Errors

StatusMeaning
400A parameter is missing or invalid. The message says which.
401Missing, unknown or revoked x-api-key.
402Your balance is lower than the call's price. Nothing was charged.
403The endpoint needs an admin key.
404The user, tweet or list does not exist or is not visible. Charged: the lookup ran.
429More than 100 requests in a minute on one key. Wait for Retry-After seconds.
503The scraper pool is busy. Retry after the Retry-After header.
5xxUpstream 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.