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"import os, requests
response = requests.get(
"https://twitterxapi.com/api/v1/users/marclou",
headers={"Authorization": f"Bearer {os.environ['TWITTERXAPI_KEY']}"},
timeout=30,
)
response.raise_for_status()
data = response.json()const response = await fetch("https://twitterxapi.com/api/v1/users/marclou", {
headers: { Authorization: `Bearer ${process.env.TWITTERXAPI_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();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…"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.