3

I'm trying to query the Twitter API v2 with free research access via tweepy in Python and it throws me this error: "When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal."

bearer_token = 'YOUR BEARER TOKEN'

# Authenticate to Twitter API
client = tweepy.Client(bearer_token=bearer_token)

# Read the tweet ids from the file
df = pd.read_csv('tweet_training_set.tsv', sep='\t')
tweet_ids = df['tweet_id'].tolist()

# Rehydrate the tweets one batch at a time
tweets = []
batch_size = 50
for i in range(0, len(tweet_ids), batch_size):
    batch = tweet_ids[i:i+batch_size]
    tweets.extend(client.get_tweets(ids=batch))

I am rehydrating the tweets 1 batch at a time otherwise it throws me the error "HTTP 431 - header too large"

My app is attached to a project

Rai
  • 63
  • 4

1 Answers1

1

What tier are you on? Free, Basic, or Enterprise? Are you also approved for Academic Research?

KrAsH3D
  • 51
  • 6