Account Rotation
Manage multiple accounts with automatic rotation.
Why Account Rotation?
Account rotation helps:
- Distribute load across accounts
- Avoid rate limits
- Improve reliability
- Enable higher throughput
Setup
Configure Multiple Accounts
typescript
const client = new XTwitterClient({
crawler: {
accounts: [
{
id: 'account1',
username: '@user1',
cookies: {
auth_token: '...',
ct0: '...'
}
},
{
id: 'account2',
username: '@user2',
cookies: {
auth_token: '...',
ct0: '...'
}
},
{
id: 'account3',
username: '@user3',
cookies: {
auth_token: '...',
ct0: '...'
}
}
],
rotation: {
cooldownMinutes: 15, // Wait 15 min between uses
maxUsesPerHour: 20 // Max 20 requests per hour per account
}
}
});How Rotation Works
- Least Recently Used: SDK picks the account used longest ago
- Cooldown Check: Skips accounts in cooldown period
- Status Check: Skips suspended accounts
- Rate Limit Check: Skips rate-limited accounts
Account Status
Accounts can have different statuses:
- active: Ready to use
- suspended: Account suspended, needs new cookies
- in_cooldown: Waiting for cooldown period
Monitoring
Use webhooks to monitor account health:
typescript
const client = new XTwitterClient({
crawler: { /* accounts */ },
webhook: {
enabled: true,
url: 'https://your-server.com/webhook',
secret: 'your-secret'
}
});You'll receive notifications when:
- All accounts are unavailable
- Only 1 account remains healthy
- Account authentication fails
Best Practices
- Use 3+ accounts for reliability
- Set appropriate cooldowns (10-20 minutes)
- Monitor with webhooks for failures
- Refresh cookies regularly (every 30 days)
- Use proxies with rotation
Next Steps
- Configuration - Account configuration
- Webhook Notifications - Monitor accounts
- Proxy Configuration - Use proxies with accounts