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

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

How to use REST API in bitbucket to populate a csv file in python ?

Hi I am currently new in using bitbucket REST api , while there are documentations out there I am currently unable to link it with my current problem. I would like to use the REST API to be able to write a script in python that will then populate a csv file with fields such as commit id , commit author , the repository where it was commited , and the branch where the commit happened in the repository ? I followed an article called while this did help me but I am unable to write a single script where the OAuth happens and I am then able to parse the json into a csv file with the above listed headers . I am looking for some suggestions currently I am using requests and json to convert the output in a dictionary to be able to loop through it but I am still unable to achieve my above listed target . I really hope if anyone could guide me for the steps I should take what end point I should ideally use and how to perform the authentication through the script (the article link requires me to copy and paste ) and then be able to extract commit id , repository , branch , commit author . Thankyou !

1 answer

0 votes

Hi @Ali Hussaini ,

You can use app passwords to authenticate and use the rest api.

For example, to list branches from repository you can use this endpoint:

response = requests.get('{workspace}/{repo_slug}/refs/branches', auth=("my-username","my-password"))


It is also possible to get all commit information for a repository/branch using this endpoint

Don't hesitate to reach out if you have any further questions


Hi @Joao Sgreccia  I really appreciate your quick response while this may get the commits in a repository it does not let me see the commits in all repositories at a glance (code committed to a repository and the branch associated with it ) what I have in mind is to create csv file which only contains the latest commits from any repository and also the branch name associated with that commit . I would like to generate graphs from my csv file and use it to analyse key parameters such as how frequently code is being committed to a particular branch of a particular repository and who is committing and generate graphs once this csv file is ready I would like to use it for business analytics.

@Ali Hussaini ,

Unfortunately, there isn't an API that returns the desired combination in one request/response.
It is necessary to use a combination of rest calls.

For example,

- Get repositories

- Get the branches

- Get commits per branch in a repository


Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,756 views 10 16
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