v2.0.0 · Open Source

Twitter Unofficial API

Login to Twitter programmatically. Supports proxies, 2FA, checkpoints, and cookie extraction.

🔐

Secure Login

Full login flow including JS instrumentation, SSO, and password steps.

🛡️

2FA & Checkpoints

Handles two-factor auth and email checkpoint verification automatically.

🌐

Proxy Support

Route requests through HTTP/HTTPS proxies for anonymity and geo-bypass.

🍪

Cookie Extraction

Extracts ct0 and full cookie string after successful login.

🔄

Auto Retry

Built-in retry logic with exponential backoff on network failures.

🐳

Docker Ready

Multi-stage Docker build. Deploy anywhere in seconds.

Live Demo

Test the login API directly from your browser.

Response
// Result will appear here...

API Reference

GET /health Health check
curl https://your-space.hf.space/health
POST /api/login Login to Twitter
{
  "username": "your_username",
  "password": "your_password",
  "email": "optional@email.com",
  "twoFactorCode": "optional_2fa",
  "checkpointCode": "optional_checkpoint",
  "proxy": "http://user:pass@host:port",
  "language": "en"
}
Success Response
{
  "success": true,
  "ct0": "abc123...",
  "cookie": "ct0=abc123; auth_token=xyz..."
}

Install as npm package

npm install twitter-unofficial-api
import { Twitter } from 'twitter-unofficial-api';

const client = new Twitter({ language: 'en' });
const result = await client.login('username', 'password');
console.log(result.cookie);