Login

POST/tw-v2/auth/login

This endpoint costs 10 request units per call.

Description

Authenticate a Twitter/X account and retrieve session cookies for use with interaction endpoints.

Rate Limit: This endpoint is limited to 60 requests per minute.

Request Body

ParameterTypeRequiredDescription
usernamestringrequiredTwitter username or email
passwordstringrequiredAccount password
twoFactorSecretstringoptionalTOTP secret (min 16 chars) for accounts with 2FA enabled. Used to auto-generate 2FA codes.
proxystringrequiredProxy in format 'hostname:port@username:password'. Required for all login requests.

Code Examples

const body = {
  username: 'yourUsername',
  password: 'yourPassword',
  proxy: 'proxy.example.com:8080@proxyUser:proxyPass'
};

const response = await fetch('https://api.tweetapi.com/tw-v2/auth/login', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(body)
});

const data = await response.json();
console.log(data);

Response

Success Response (200 OK)

200
{
  "status": "success",
  "data": {
    "cookies": {
      "auth_token": "a1b2c3d4e5f6g7h8i9j0",
      "ct0": "x9y8z7w6v5u4t3s2r1q0p9o8n7m6l5k4",
      "twid": "\"u=1234567890123456\"",
      "kdt": "AbCdEfGhIjKlMnOpQrStUvWxYz123456",
      "__cf_bm": "aBcDeFgHiJkLmNoPqRsTuVwXyZ-1234567890.123456-1.0.1.1-AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKl"
    },
    "user": {
      "id": "1234567890123456",
      "username": "exampleUser",
      "name": "Example User"
    },
    "timestamp": "2025-11-28T10:41:10.196Z"
  }
}

Error Responses

400s Errors

401INVALID_CREDENTIALS
401TWO_FACTOR_REQUIRED
401INVALID_TWO_FACTOR_CODE
403ACCOUNT_SUSPENDED
403ACCOUNT_LOCKED
429RATE_LIMITED

500s Errors

502PROXY_ERROR

API Playground

POST/tw-v2/auth/login

Press ⌘ + Enter to execute

curl -X POST "https://api.tweetapi.com/tw-v2/auth/login" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"
Response

Click "Try It!" to see the response