I am trying to write some code that will take the rate limiting features into account for me but I am getting some confusing results. I keep getting responses with status 429 “Too Many Requests” even though I am trying to have my code wait for the reset whenever it runs out of requests. In fact the headers don’t appear to show a problem at all. The value I got for the header ‘x-rate-limit-remaining’: was 189 so either there is some inconsistency between the information in the header and the actual calculated rate limit or there is some other information that I am unaware of that I need to be tracking as well?

1 Like

Which endpoint are you trying to check? Is is a read endpoint, or read/write (POST)?

This is a read endpoint. I am just searching for tweets that match a search string during different time windows.

Just clarifying as well, this is on the v2 API search endpoint? Are you using a bearer token? Can you share more detail?

I am using the v2 API search endpoint and using a bearer token. I would be happy to provide any additional information that could possibly help diagnose the issue.

Some more information: I am interested in tweet replies to specific topics as a function of time so I am searching for tweets within a specific short time window, storing those results, decrementing the time window (to move further back) and sending out a new query for that time window. I have been trying to use the x-rate-limit-remaining header to work out when to space between queries. I am making sure to check the rate limit, and sleep if appropriate, before I send out the next query. I also made sure to add a few buffer seconds to the sleep duration beyond the time until reset that the header provides.

Broadly speaking, the x-rate-limit headers are not specific to v2 at this time and there is no “usage” API for v2 at this time. I have asked some folks internally for more information to better inform how I reply to your question, but the rate limits listed in the v2 API reference documentation are the main ones to work with.

1 Like

I’m not sure I follow fully. Are you saying that the x-rate-limit headers might not be accurate for the v2 API and that I should be trying to track the number of queries and time myself?

Yes, that is correct. I am working to get more clarity on this.

1 Like

I see, thank you. I look forward to any additional guidance you can provide.