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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,463,054
Community Members
 
Community Events
176
Community Groups

Getting branches from a repository via bitbucket Rest API

Edited

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:

https://api.bitbucket.org/2.0/repositories/<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": "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/watchers"
      },
      "branches": {
      "href":       "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches"
},
....

So you can hit the endpoint and get the branches:


https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches
# GET /2.0/repositories/{workspace}/{repo_slug}/refs/branches

And get a specific branch with


https://api.bitbucket.org/2.0/repositories/{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
TAGS

Atlassian Community Events