Hello fellow overflowers.
I'm new to Twitter API. I'm using python. I'm using Tweepy library. I have the elevated access of twitter API, and I'm trying to get the rate limit information of the 15 min window.
Reference of what I want in twitter docs :
Twitter Docs : https://developer.twitter.com/en/docs/twitter-api/rate-limits#headers-and-codes
I did a bit of search but cannot find anything on how to do it. I found this Github sample code from twitter but still nothing: https://github.com/twitterdev/Twitter-API-v2-sample-code
And also on Tweepy I couldn't find anything: https://docs.tweepy.org/en/stable/client.html
But I can see the amount of requests when I use the request live from twitter self, but it's only 180 requests per 15 min, so its using the User-rate-limit and not the application-rate-limit :
Does anyone know how to do this ? Thnx in advance👌.
The function search_recent_tweets from tweepy.Client returns an object with type tweepy.client.Response, which does not contain information regarding rate limits. Unfortunately, this means you won't be able to get it using tweepy.
An alternative could be to make the request yourself with a code like this:
import requests
def bearer_oauth(r):
r.headers["Authorization"] = f"Bearer {bearer}"
return r
bearer = "your bearer token"
params = {"query": "your search"}
response = requests.get("https://api.twitter.com/2/tweets/search/recent", params=params, auth=bearer_oauth)
After running that code, you will find rate limit information on response.headers.