Login
POST
/tw-v2/auth/loginThis 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | required | Twitter username or email |
| password | string | required | Account password |
| twoFactorSecret | string | optional | TOTP secret (min 16 chars) for accounts with 2FA enabled. Used to auto-generate 2FA codes. |
| proxy | string | required | Proxy 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
401
INVALID_CREDENTIALS401
TWO_FACTOR_REQUIRED401
INVALID_TWO_FACTOR_CODE403
ACCOUNT_SUSPENDED403
ACCOUNT_LOCKED429
RATE_LIMITED500s Errors
502
PROXY_ERRORAPI Playground
POST
/tw-v2/auth/loginPress ⌘ + 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