Skip to content

Timespan for Elevated Access to Historical Twitter Data

I have a developer account as an academic and my profile page on twitter has Elevated on top of it, but when I use Tweepy to access the tweets, it only scrapes tweets from 7 days ago. How can I extend my access up to 2006?

This is my code:

import tweepy
from tweepy import OAuthHandler
import pandas as pd

access_token = '#'
access_token_secret = '#'
API_key = '#'
API_key_secret = '#'

auth = tweepy.OAuthHandler(API_key, API_key_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth, wait_on_rate_limit=True)

tweets = []

count = 1

for tweet in tweepy.Cursor(api.search_tweets, q= "#SEARCHQUERY", count=5000).items(50000):
    count += 1

        data = [tweet.created_at,, tweet.text,
tweet.user._json['screen_name'], tweet.user._json['name'], tweet.user._json['created_at'], tweet.entities['urls']]
        data = tuple(data)

    except tweepy.TweepError as e:

    except StopIteration:

df = pd.DataFrame(tweets, columns = ['created_at','tweet_id', 'tweet_text', 'screen_name', 'name', 'account_creation_date', 'urls'])

df.to_csv(path_or_buf = 'local address/file.csv', index=False)



The Search All endpoint is available in Twitter API v2, which is represented by the tweepy.Client object (you are using tweepy.api).

The most important thing is that you require Academic research access from Twitter. Elevated access grants addition request volume, and access to the v1.1 APIs on top of v2 (Essential) access, but you will need an account and Project with Academic access to call the endpoint. There’s a process to apply for that in the Twitter Developer Portal.

User contributions licensed under: CC BY-SA
5 People found this is helpful