simple API wrapper to interact with twitter's unofficial API.
You can log in to Twitter using your account username, email address and password and use most features on Twitter, such as posting and retrieving tweets, liking and following users.
If you have any questions, please ask on Discord.
This library uses the unofficial API, therefore does not require an API key.
This library is completely free to use.
Whether you prefer synchronous or asynchronous programming,
Twikit supports both, providing flexibility for different use cases.
This library allows you to perform various Twitter-related actions, including:
-
Create tweets
-
Search tweets
-
Retrieve trending topics
-
etc...
pip install twikit
Define a client and log in to the account.
from twikit import Client
USERNAME = 'example_user'
EMAIL = '[email protected]'
PASSWORD = 'password0000'
# Initialize client
client = Client('en-US')
# Login to the service with provided user credentials
client.login(
auth_info_1=USERNAME ,
auth_info_2=EMAIL,
password=PASSWORD
)
Create a tweet with media attached.
# Upload media files and obtain media_ids
media_ids = [
client.upload_media('media1.jpg'),
client.upload_media('media2.jpg')
]
# Create a tweet with the provided text and attached media
client.create_tweet(
text='Example Tweet',
media_ids=media_ids
)
Search the latest tweets based on a keywords
tweets = client.search_tweet('python', 'Latest')
for tweet in tweets:
print(
tweet.user.name,
tweet.text,
tweet.created_at
)
More Examples: examples
I would like to hear your thoughts and suggestions.
If you have any features you'd like to see added or encounter any issues,
please let me know in the issues section.
Additionally, if you find this library useful, I would appreciate it if you would star this repository or share this library⭐! Thank you very much!