skip to Main Content

Does anyone know how to use the search_full_archive feature in tweepy module? I used the cursor feature similar to the regular search, but it didn’t work.

import tweepy as tw

api_key = '***'
api_secret_key = '***'
access_token = '***'
access_token_secret = '***'

#Authenticate
auth = tw.OAuthHandler(api_key, api_secret_key)
auth.set_access_token(access_token,access_token_secret)
api = tw.API(auth)

# search tweets
def get_tweets_full(hashtag):
    tweetObj_full = tw.Cursor(
        self.api.search_full_archive,
        environment_name = 'VolcanicDisaster', # Dev environment label from twitter developer dashboard
        query = hashtag
    )
     return tweetObj

get_tweets(hashtag = '#kilauea')

I get an error stating ‘API object has no attribute search_full_archive’. However, if I use the regular search method api.search (with its parameters q) instead of api.search_full_archive it works fine. I want to look back for tweets from 2 years ago and require api_full_search, wondering if anyone knows how to use this feature?
I have managed set up the premium account (sandbox version – free) with twitter API, but when I input dir(api) I don’t see the search_full_archive method in the output list of methods.

2

Answers


  1. Search full archive feature is only available on Premium and Enterprise Api accesses. Free API users can only have access to recent tweets (recent 7 days).

    Reference: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/overview

    Login or Signup to reply.
  2. Firstly, full archive features only available on Premium/Enterprice API. But you can also upgrade your standart developer account to Premium for FREE in limited.

    Secondly, tweepy with version 3.10.0, the full archive feature is supported!!! But you need to update tweepy. Currently it is not possible to update with pip so you need to update as pip install --upgrade git+https://github.com/tweepy/tweepy@master. Then your API will ready to use,

    Lastly, with the documentation of tweepy you need to redescribe your API. Here is 2 example of tweepy API object;

    search_words ='**KEYWORD/HASHTAG/USERNAME**'
    date_since = "13-08-2020"
    date_since_pro = "202008130000"
    numTweets = 100
    
    # standart search
    tweets = tweepy.Cursor(api.search, q=search_words, since=date_since).items(numTweets)
    
    # premium search
    tweets=tweepy.Cursor(api.search_full_archive,environment_name='**ENV NAME FROM API**', query=search_words, fromDate=date_since_pro).items(numTweets)
    

    As you see the need to change date format with search_full_archive feature.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search