osome-iu / botometer-python

A Python API for Botometer by OSoMe
https://botometer.osome.iu.edu
MIT License
371 stars 59 forks source link

How can I check how much daily quota I have left in Pro API? #38

Closed abaheti95 closed 4 years ago

abaheti95 commented 4 years ago

Is there any way to know how much of the daily quota I have used while running a code? Can I automatically wait until the next day when the API refreshes the quota limit? How and when is this limit refreshed?

clayadavis commented 4 years ago

Since Botometer's ratelimits reflect those of Twitter, you can handle ratelimiting via the underlying Tweepy library. You have two choices:

  1. Use a try/except clause to catch Tweepy's RateLimitError and handle it appropriately.
  2. Use the optional wait_on_ratelimit=True in the Botometer constructor, as shown in the README:
    bom = botometer.Botometer(wait_on_ratelimit=True,
                              rapidapi_key=rapidapi_key,
                              **twitter_app_auth)

If you use a single Botometer Pro account with a single set of Twitter keys, you shouldn't ever have an issue with overage charges on RapidAPI.

abaheti95 commented 4 years ago

What if I plan to use muliple twitter keys with the same RapidAPI key. How can I stop for overshooting in that scenario?