Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get total number of commits using Bitbucket REST API

msteppe91
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 11, 2022

Following the request format:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits

and adding the withCounts parameter as documented here (https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8283059312), I do not get the total number of commits. I only seem to get the total commits on the page of results I’m requesting. The count does not include results from other results pages if the limit parameter paginates the values. 

Is this limitation by design or is this a bug? I am looking for the total commit number before running a python script asynchronously to speed up the requests returned from the server. 

Thanks!

2 answers

0 votes
Carol December 29, 2023

The documentation says the response should provide the size:

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commits-get 

The documentation also states that we could use Bearer access token.

In summary, it looks like the documentation is very outdated. 

Any chance that there's a way to get the commits number without iterating every page?

0 votes
Eric Lebel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 26, 2023

did you get an answer? the solution involve getting each page with curl calls... way too long for us too. 

You can modify this great script  by mikev0546 but it is really not a solution for us too.

counter.py

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events