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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Getting branches from a repository via bitbucket Rest API


Hello, community.

I am looking for the list of endpoints available for bitbucket API regarding get the branches from a repository and a specific branch.

I was expecting to see something like:

GET /2.0/repositories/{workspace}/{repo_slug}/branches/

GET /2.0/repositories/{workspace}/{repo_slug}/branches/{branch}

So I can get the commits from a specific branch. 

I know I can get commits but with this endpoint, its scope is under repository perspective. 

Do you know if there are endpoints to work with branches and recursively into its hierarchy?
I looked over the documentation but I did not see what I was looking for so that is why I am posting this question here.

In addition, I see some time ago that was not possible according to this question. Is it still true? 

1 answer

1 accepted

0 votes
Answer accepted

When hitting this endpoint:<workspace>/<repository-name>`
# GET /2.0/repositories/{workspace}/{repo_slug}

You get as a result a JSON document. In the `links` attribute you got a key called `branches`. It is something like this:


"scm": "git",
"has_wiki": false,
      "links": {
      "watchers": {
            "href": "{workspace}/{repo_slug}/watchers"
      "branches": {
      "href":       "{workspace}/{repo_slug}/refs/branches"

So you can hit the endpoint and get the branches:{workspace}/{repo_slug}/refs/branches
# GET /2.0/repositories/{workspace}/{repo_slug}/refs/branches

And get a specific branch with{workspace}/{repo_slug}/refs/branches/<branch-name>
# GET /2.0/repositories/{workspace}/{repo_slug}/refs/branches/<branch-name>

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events