Quickstart
This guide will help you make your first Twitter API calls with Twikit. By the end, you’ll have a working script that authenticates with Twitter and searches for tweets.This guide assumes you’ve already installed Twikit. If not, install it first with
pip install twikit.Your first Twikit script
Let’s create a simple script that logs in to Twitter and searches for tweets.Initialize the client
Create a Twikit client instance with your preferred language:The language parameter affects the language of content returned by Twitter’s API.
Complete example
Here’s the full script in one place:twitter_bot.py
Understanding async/await
Twikit is built with asynchronous Python, which means all client methods are coroutines that must be called withawait.
Common operations
Here are some common operations you can perform with Twikit:Get a user’s profile
Create a tweet
Get user tweets
Like and retweet
Pagination
Many methods return paginated results. Use thenext() method to fetch more:
Best practices for testing
Use cookies to avoid repeated logins
Instead of logging in every time you run your script, save and reuse cookies:Rate limits
Twitter enforces rate limits on various operations. Most limits reset every 15 minutes.Common rate limits
Common rate limits
- Search tweets: 50 requests per 15 minutes
- Get user tweets: 50 requests per 15 minutes
- Get user info: 95-500 requests per 15 minutes (varies by endpoint)
- Follow user: 15 requests per 15 minutes
- Get trends: 20,000 requests per 15 minutes
Error handling
Always handle potential errors in your Twikit applications:Next steps
Now that you’ve made your first Twikit script, explore these topics:Authentication
Learn about secure authentication and cookie management
API Reference
Explore all available methods and their parameters
Examples
Browse example scripts for common use cases
Join Discord
Get help and connect with the Twikit community
