tweepy
If you're using a method that performs an action on behalf of the authenticating user, e.g. API.update_status
, make sure your app has the write permission.
After giving it the write permission, make sure to regenerate and use new credentials to utilize it.
See Twitter's API documentation on app permissions for more information.
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 Stream
.
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.
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 tweet_gif
or tweet_video
.
Also make sure your video follows the recommended specifications.
See Twitter's API documentation on media best practices for more information.
"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."
https://twittercommunity.com/t/inconsistent-tweet-retrieval/150635
Twitter's standard search API only "searches against a sampling of recent Tweets published in the past 7 days."
If you're specifying an ID range beyond the past 7 days or there are no results from the past 7 days, then no results will be returned.
See Twitter's documentation on the standard search API for more information: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/overview https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets
This and other similar errors are due to Tweepy v4.0.0 <Version 4.0.0>
changing API
methods to no longer accept arbitrary positional arguments. The 1 positional argument being referred to in the error is self
.
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 me
attribute.
This is because Tweepy v4.0.0 <Version 4.0.0>
removed API.me
.
Instead, you can use API.verify_credentials
.
If you're attempting to use API.search
or other API
methods from Tweepy v3, you might encounter an AttributeError
with Tweepy v4.
This is because Tweepy v4.0.0 <Version 4.0.0>
renamed many API
methods to be more consistent.
For example, API.search
was renamed to API.search_tweets
. You can refer to the changelog / release notes and update your method invocations accordingly.
If you're attempting to import StreamListener
with Tweepy v4, you'll get an AttributeError
about tweepy
not having a StreamListener
attribute.
This is because Tweepy v4.0.0 <Version 4.0.0>
merged StreamListener
into Stream
.
To use Tweepy v4, you'll need to update your code to subclass Stream
instead.
If you are simply printing the objects and looking at that output, the string representations of API v2 models/objects only include the default attributes that are guaranteed to exist.
The objects themselves still include the relevant data, which you can access as attributes or by key, like a dictionary.
There's also a data
attribute/key that provides the entire data dictionary.
Paginator.flatten
flattens the data
and iterates over each object.
To access includes
, you'll need to iterate through each response instead.
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 Paginator
.
You can time.sleep
1 second while iterating through responses to handle this rate limit.