Docs menu: Quickstart

Quickstart

Get a key, read a profile, then page through a collection.

1. Get an API key

Sign in with Google. Copy the key from the dashboard into an environment variable:

Shell
export TWITTERXAPI_KEY="tx_live_..."

2. Make a request

Base URL https://twitterxapi.com/api. Send the key as a bearer token.

curl "https://twitterxapi.com/api/v1/users/marclou" \
  -H "Authorization: Bearer $TWITTERXAPI_KEY"

3. Read the response

A profile lookup returns one account (saved from a live call, shortened):

200 OK
{
  "id": "2311987360",
  "username": "marclou",
  "followersCount": 382499,
  "followingCount": 1246,
  "statusesCount": 36756,
  "verified": false
}

Keep id as a string; X IDs exceed JavaScript's safe integer range. Other response levels

A missing or wrong key returns 401:

401 Unauthorized
{
  "detail": "invalid or missing bearer token",
  "error": {
    "code": "unauthorized",
    "message": "invalid or missing bearer token",
    "requestId": "8f2c…"
  }
}

4. Get the next page

Collections return a page and a cursor:

Page shape
{
  "items": [ … ],
  "count": 20,
  "pagination": { "next_cursor": "DAABCgAB…", "has_more": true }
}

Send next_cursor back unchanged as cursor:

cURL
curl -G "https://twitterxapi.com/api/v1/users/marclou/tweets" \
  -H "Authorization: Bearer $TWITTERXAPI_KEY" \
  --data-urlencode "cursor=DAABCgAB…"

Full loops in Python and JavaScript

Key safety

  • Call the API from a server or script, not browser code.
  • If the key leaks, replace it in the dashboard. The old key stops working at once.
  • The same key works for REST and the MCP server.