user2766182
user2766182

Reputation: 3

Rate limit exceeded in tweepy

I faced with a limitation problem using tweepy. I am recieving Rate limit exceeded error every time running script. I need to know is there any way to know how many requests may I do before Rate limit exceeded error occured.

Upvotes: 0

Views: 3622

Answers (2)

Terence Eden
Terence Eden

Reputation: 14334

Tweepy offers access to the Rate Limit API.

From their documentation

import tweepy

consumer_key        = 'a'
consumer_secret     = 'b'
access_token        = 'c'
access_token_secret = 'd'

# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

# Creation of the actual interface, using authentication
api = tweepy.API(auth)

# Show the rate Limits
print api.rate_limit_status()

You'll then see a list of all the available rate limits and how many calls you have remaining.

For example:

{ "rate_limit_context" : { "access_token" : "1234" },
  "resources" : { "account" : { "/account/login_verification_enrollment" : { "limit" : 15,
              "remaining" : 15,
              "reset" : 1411295469
            },
          "/account/settings" : { "limit" : 15,
              "remaining" : 15,
              "reset" : 1411295469
            },
          "/account/update_profile" : { "limit" : 15,
              "remaining" : 15,
              "reset" : 1411295469
            },
          "/account/verify_credentials" : { "limit" : 15,
              "remaining" : 15,
              "reset" : 1411295469
            }

Upvotes: 3

Talvalin
Talvalin

Reputation: 7889

The rate limits can be found in the Twitter API documentation:

https://dev.twitter.com/docs/rate-limiting/1#rest

Upvotes: 0

Related Questions