Hi,
I have an application that accesses repository data in BitBucket cloud via the API like so:
https://api.bitbucket.org/2.0/repositories/{username}/{repo}/refs/branches/master
In the last few days the application started receiving a lot of "429 TooManyRequests" errors, seemingly without increasing the amount of calls being made.
All the calls are authenticated with the same user.
As far as I understand from here the rate limit for such calls is a rolling window of 1000 requests per hour, right?
I have a few questions that might help me find what is causing the issue:
1. The error responses include the X-Request-Count header - what is the meaning of this header and its value?
Is it the total number of requests made in the rolling hour?
If so, then the header's value in a "429 TooManyRequests" response should always be over 1000, right?
The reason I'm asking is that in some responses the header value was much lower than that, e.g. 268, 308, 811 - how can this be explained?
2. Another strange observation regarding the X-Request-Count header is that sometimes 2 error responses received at the same time (on the second) contain vastly different values.
For example, 268 in one response and 1570 in another.
How is that possible?
Can this indicate an issue with the API rate limiting logic? Are there any known issues in this area?
3. Most of the API calls made by the application is to get the details of a branch in the repository (the url example above).
This request is made with the If-None-Match header set to the branch's latest etag value and when successful, the call returns "304 NotModified" status code.
Do such requests count against the API rate limit (1000)?
As far as I know, in Github they are not.
4. Another frequent API call made by the application is to obtain access tokens via the "https://bitbucket.org/site/oauth2/access_token" url.
Do those calls count against the same rate limit of 1000 requests per hour?
5. In general, were there any changes lately to the way API rate limits are calculated?
Any insights will be highly appreciated.