Frequently Asked Questions
Why am I encountering a 403 Forbidden error with
If you have Essential access to the Twitter API, you won’t be able to access
Twitter API v1.1. This includes all
API methods and
You can use Twitter API v2 with
Client or apply for Elevated access.
See the Twitter API access levels and versions documentation for more information.
Why am I encountering issues when attempting to upload GIFs or videos?
If you are encountering a 400 Bad Request error when uploading large GIFs or
other errors/issues with uploading videos, make sure to pass the
media_category parameter, e.g. as
Also make sure your video follows the recommended specifications.
See Twitter’s API documentation on media best practices for more information.
Why am I getting an inconsistent number of / not getting 3200 Tweets for a specific user?
“For very high volume and high traffic accounts, be aware that the Twitter API is highly distributed and eventually consistent. We strive to provide current information but like any large scale system, you may see unexpected behaviours at high volumes.”
Why am I getting a
TypeError about an
API method taking 1 positional argument but given 2?
This and other similar errors are due to
Tweepy v4.0.0 changing
to no longer accept arbitrary positional arguments. The 1 positional argument
being referred to in the error is
These parameters can be passed as keyword arguments instead.
Refer to the documentation for the
API method being used.
If you’re attempting to use
API.me with Tweepy v4, you’ll get an
AttributeError about the
API object not having a
This is because Tweepy v4.0.0 removed
Instead, you can use
If you’re attempting to import
StreamListener with Tweepy v4, you’ll get an
tweepy not having a
This is because Tweepy v4.0.0 merged
To use Tweepy v4, you’ll need to update your code to subclass
Twitter API v2
Why am I not getting expansions or fields data with API v2 using
If you are simply printing the objects and looking at that output, the string representations of API v2 models/objects only include the default fields that are guaranteed to exist.
The objects themselves still include the relevant data, which you can access as attributes or by subscription.
There’s also a
data attribute/key that provides the entire data dictionary.
How do I access
includes data while using
Paginator.flatten() flattens the
data and iterates over each object.
includes, you’ll need to iterate through each response instead.
Why am I getting rate-limited so quickly when using
The GET /2/tweets/search/all Twitter API endpoint that
Client.search_all_tweets() uses has an additional 1 request per second
rate limit that is not handled by
time.sleep() 1 second while iterating through responses to handle
this rate limit.