Overview
When Twitter locks your account (error code 326), you’ll be prompted to solve a FunCAPTCHA challenge to regain access. Instead of manually solving these CAPTCHAs, you can configure Twikit to automatically unlock your account using Capsolver.Capsolver is a third-party CAPTCHA solving service. You’ll need to sign up at capsolver.com and obtain an API key.
Setting up Capsolver
First, initialize the Capsolver instance with your API key:Configuration parameters
api_key(required): Your Capsolver API key obtained from capsolver.commax_attempts(optional): Maximum number of attempts to solve the CAPTCHA (default: 3)get_result_interval(optional): Time in seconds between result checks (default: 1.0)use_blob_data(optional): Whether to use blob data in requests (default: False)
How it works
When you initialize the client with acaptcha_solver, Twikit automatically handles account locks:
Account lock detection
When Twitter returns error code 326, Twikit detects that your account is locked
Automatic unlocking
If
auto_unlock=True (the default), Twikit automatically calls the unlock processCAPTCHA solving
The Capsolver service solves the FunCAPTCHA challenge and returns the solution token
Manual unlocking
You can also manually trigger the unlock process:ValueError if no captcha solver is provided.
When CAPTCHAs are triggered
Twitter’s anti-bot detection may lock your account and require CAPTCHA verification in several situations:- Too many requests: Sending requests too quickly or exceeding rate limits
- Suspicious patterns: Automated behavior that doesn’t match normal user activity
- Multiple logins: Logging in repeatedly from different IPs or locations
- Account creation: New accounts are more likely to trigger verification
- Sensitive actions: Mass following, unfollowing, or messaging
Troubleshooting
”Captcha solver is not provided” error
This error occurs when your account is locked but you haven’t configured a CAPTCHA solver:Solver fails after max attempts
If the CAPTCHA solver fails after reachingmax_attempts, you’ll receive an exception:
- Increase the
max_attemptsparameter - Check your Capsolver API key and account balance
- Verify your proxy configuration (if using one)
- Try adjusting the
use_blob_dataparameter
Capsolver API errors
If you see error responses from Capsolver:- Error ID 1: Service is temporarily unavailable, the solver will retry
- Invalid API key: Verify your API key is correct
- Insufficient balance: Add funds to your Capsolver account
Best practices
- Store API keys securely: Use environment variables instead of hardcoding API keys
- Set reasonable max_attempts: 3-10 attempts is usually sufficient
- Combine with rate limiting: Use CAPTCHA solving alongside proper rate limiting
- Monitor costs: Track your Capsolver usage to manage costs
- Use proxy rotation: Combine CAPTCHA solving with proxy rotation for better results
