It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket REST API Rate Limiting ?

I'm downloading a list of commits through the Bitbucket REST API, and I'm running into the flowing message:

AppError: Rate limit for this resource has been exceeded.

There is information on the rate limits here: https://confluence.atlassian.com/bitbucket/rate-limits-668173227.html

However, there isn't a lot of information around how they work, when they reset, or what the timeout is. I would like to modify my download script in a way that can download the full list of commits, while still respecting the limits.

2 answers

I may be missing something, but rather than using the API could you clone the entire repo and extract the list of commits locally?

I'm not able to find an endpoint to clone the repository from the OAuth Credentials.

seanaty Atlassian Team Jun 04, 2019

I realize that this is a year late, but in case anyone lands here, you can use an oauth access token to clone repos as described on this page: https://developer.atlassian.com/bitbucket/api/2/reference/meta/authentication

Repository Cloning

Since add-ons will not be able to upload their own SSH keys to clone with, access tokens can be used as Basic HTTP Auth credentials to clone securely over HTTPS. This is much like GitHub, yet slightly different:

$ git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git

The literal string x-token-auth as a substitute for username is required (note the difference with GitHub where the actual token is in the username field).

Like Jeremy_Freeman likes this

Thanks for that @seanaty I had since found this, and have started using it.  

0 votes
Ana_Retamal Atlassian Team Feb 28, 2018

Hi Jeremy, rate limits are divided into one hour windows for both authenticated and unauthenticated requests. To obtain a list of repository commits, the rate is 1,000 requests per hour. Once you reach it you'll need to wait until 1 hour has passed so you can continue sending requests.

Hope this clarifies!

Ana

So, does that mean If I make 1000 requests from 9:45 to 9:59, I can then make 1000 more requests from 10:01-10:15.

Is the one hour window based on clock time? is it a rolling count? Does it start with the last request?

My workload is bursty, so, I would like some clarification around how it's calculated to better prepare for this.

Hi Jeremy, 

It's the rolling count I believe , not by clock hour. 

Cheers.

Yana

Thanks!  Is there no official documentation on this behavior, aside from the above link?

Hi Jeremy, 

The document linked above is what we have available right now. 

If you do get more questions or need clarification on anything please do get in touch via the community or raise a support ticket with us.

Cheers.

Yana

I'm responding to this to add to the documentation.  My tests confirmed that it's a rolling count.

Like # people like this

@Ana_Retamal your comment here contradicts the documentation 

Rate limits are divided into a one-hour rolling window for both authenticated and unauthenticated requests, which means that for every minute that passes, you will be provided that time to run new requests but the total you can run consecutively over an hour is 1,000. 

That would imply that when you hit the limit, you may only have to wait 1 minute to have some requests available. For example, if I send 500 requests at 3:33 and 500 requests at 4:32, as soon as it ticks 4:33, you'll get those first 500 requests back. But if I send all 1000 requests at 4:32, I'll have to wait until 5:32 to send another request.

... assuming my understanding of the documentation and its intended meaning are the same thing.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Bitbucket Server 7.0 is here!

Hello Community, I’m Anton Genkin, a product manager on the Bitbucket Server and Data Center team and am excited to share that Bitbucket Server 7.0 is now available! It's a platform release, one th...

994 views 6 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you