Reputation: 99
How do I avoid being rate limited on twitter premium API? I can get a new endpoint but, how do I avoid making that mistake. I need to pull a lot of tweets from a lot of days. I have even tried the same endpoint after 5 hours, still getting the same error.
from searchtweets import collect_results,ResultStream, gen_rule_payload, load_credentials
import csv
premium_search_args = load_credentials("E:\\residency_5\\practicum\\twitter_keys.yaml",yaml_key="search_tweets_premium",env_overwrite=False)
rule = gen_rule_payload("#whistlepodu", to_date="2018-04-07",from_date="2018-04-08", results_per_call=100)
print(rule)
tweets = collect_results(rule,
max_results=5,
result_stream_args=premium_search_args)
csvFile = open('E:\\residency_5\\practicum\\whistlepodu\\2.csv', 'a')
csvWriter = csv.writer(csvFile)
for tweet in tweets:
csvWriter.writerow([str(tweet.created_at_datetime), tweet.all_text.encode('utf-8'),tweet.hashtags,tweet.favorite_count,tweet.retweet_count])
csvFile.close()
I am getting the following error:
retrying request; current status code: 429
retrying request; current status code: 429
retrying request; current status code: 429
HTTP Error code: 429: Request exceeds account’s current query limits. Please upgrade to the next package level and retry.
Rule payload: {'query': '#whistlepodu', 'maxResults': 100, 'toDate': '201804070000', 'fromDate': '201804080000'}
Any advice or tip is appreciated. Thanks in advance :)
Upvotes: 0
Views: 1457
Reputation: 51
https://developer.twitter.com/en/docs/ads/general/guides/response-codes.html as you see here these error codes mean that you reached TOO_MANY_REQUESTS or TWEET_RATE_LIMIT_EXCEEDED.
Upvotes: 1