skip to Main Content

I want to access Twitter’s archive without being restricted by rate limits or number of queries. I don’t mind paying for this, so my plan was to sign up for the premium package on Twitter’s API platform. As I’m familiar with Tweepy, I had hoped to be able to access the API in my usual way.

However, it seems that the only way I can query the API with premium credentials in Python is through the Python Twitter Search API, which is basically a python wrapper for the premium service. The issue is that the authentication protocols for premium access are not the same as for the rate-limited free access. This is most annoying, as the searchtweets library that supports the Python Twitter Search API seems fairly primitive, and I can make practically no sense of the docs.

Does anyone know whether it is possible to use Tweepy to access premium tier for Twitter? It’s kinda weird that the better tools only work on the free tier.

2

Answers


  1. That is not true. You can use the same credentials (assuming you get authorized by Twitter) for both the Standard Search and the Premium Search.

    The TwitterAPI python wrapper supports both — https://github.com/geduldig/TwitterAPI

    from TwitterAPI import TwitterAPI
    api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)
    r = api.request('tweets/search/fullarchive/:YOUR_LABEL',
                    {'query':YOUR_SEARCH_TERMS})
    for item in r:
        print(item)
    
    Login or Signup to reply.
  2. Tweepy now supports the premium API as discussed here. I had to install from github rather than pip. See the documentation for API.search_30_day and API.search_full_archive and the corresponding documentation for the premium search APIs.

    pip install --upgrade git+https://github.com/tweepy/tweepy@master
    

    The api is different. api.search becomes api.search_full_archive or api.search_30_day.

    # premium search
    tweets=tp.Cursor(api.search_full_archive,environment_name='you_env_name_here', query=search_words, fromDate=date_since).items(100)
    
    # free search
    tweets=tp.Cursor(api.search, q=search_words, lang="en",since=date_since).items(100)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search