简体   繁体   中英

twitter api rate limit issue

I'm trying to query tweet using tweepy by tweet ids (about 2300 ids) but i can only query around 185 ids each time and then have to wait for 15mins, which means that 2300 ids will take about 3 hrs to complete.

the api im using is:

consumer_key = 'xxxxxx'
consumer_secret = 'xxxxxx'
access_token = 'xxxxxxxx'
access_secret = 'xxxxxx'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

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

then loop through each id in tweet_id with api.get_status method

I did google around and turns out that possibly app-only queries allows more request within 15min windows, can anyone please point out how can i make an app-only request with tweepy ?

thanks

You can use the statuses_lookup ( tweepy docs , twitter docs ) instead, and pass up to 100 ids per call. The limit with using this method is 300 requests according to the rate limits page . That is, you could get 300x100=30000 tweets before reaching the window limit and having to wait for 15 minutes. Your 2300 ids would be collected really quick.

Hope it helps

UPDATE to answer comment:

From the Twitter docs:

If a requested Tweet is unknown or deleted, then that Tweet will not be returned in the results list, unless the map parameter is set to true, in which case it will be returned with a value of null.

So you won't really get an error, but you may not get the tweet. So you would want to compare the returned results against your ID list to see which tweet was not returned.

I believe you can do application only authentication with tweepy 2.0

Read this: https://shogo82148.github.io/blog/2013/05/09/application-only-authentication-with-tweepy/

I hope this helped!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM