Registry / http-networking / twikit

twikit

JSON →
library2.3.3pypypi✓ verified 86d ago

Twikit is an asynchronous Twitter API wrapper for Python that works without an official API key by scraping the web interface. Current version 2.3.3, updated frequently (multiple releases per month). Supports Python >=3.8.

pip install twikit
INSTALL
IMPORT
SIG · TWIKIT
T
twikit
http-networkingpythonv2.3.3
Install
5.4s avg
Import
2438ms
Disk
47MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.944s · 46MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.4s · import 1.956s · 46MB
47MB installed
● package 47MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from twikit import Client

Login and fetch a user by screen name.

import asyncio from twikit import Client async def main(): client = Client('en-US') await client.login(auth_info_1='your_username', password='your_password') user = await client.get_user_by_screen_name('example_user') print(user.screen_name) asyncio.run(main())
Debug
Known issues
breakingFrom version 2.0.0, twikit switched from synchronous to asynchronous API. All methods must be awaited. Old sync code using `client.get_tweets()` will fail.
fix
Wrap calls in async functions and use `await`. Install httpx[socks] if using proxies.
affects: >=2.0.0
gotchaTwikit can get rate-limited or have your account suspended if used aggressively. No official API means scraping is fragile.
fix
Add delays between requests, use random intervals, and rotate accounts if needed.
affects: all
deprecatedThe `get_tweets()` method is deprecated. Use `get_user_tweets()` instead.
fix
Replace `client.get_tweets(user_id)` with `client.get_user_tweets(user_id)`.
affects: >=2.0.0
gotchaLogin may require cookies if email confirmation or 2FA is enabled. The library does not handle OTP automatically.
fix
Pass `cookies` parameter or manual OTP entry via CLI.
affects: all
Errors
Common errors & fixes
TypeError: Client() takes no arguments
Older versions (<2.0) used `Client('en-US')` as positional. New version expects `lang` keyword.
fix
Use `Client(language='en-US')` or simply `Client('en-US')` still works in 2.x but best to use keyword.
AttributeError: module 'twikit' has no attribute 'Client'
Incorrect import path (e.g., `from twikit.client import Client`).
fix
Use `from twikit import Client`.
twikit.errors.TooManyRequests: Rate limit exceeded
Sending too many requests in a short time.
fix
Add `time.sleep()` or use a delay between requests. Use rotating proxies.
Upgrade
Version history
2.3.3latest on PyPI · released Feb 7, 2025
Audit
Dependencies
httpxrequiredHTTP client for async requests
httpx-sserequiredServer-sent events support for real-time features
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
twikit — pip install twikit · libregistry