Use Bitbucket API for managing projects

It’s a convenient way for doing repetitive tasks for collecting information about the repositories, commits, branches ..

Photo by William Bout on Unsplash

Bitbucket API now has REST API version 2.0 but in this post, we will go with version 1.0 since I do not have bitbucket server for version 2.0 now. But it’s ok. The idea is showing you guys some functionalities that Bitbucket API supports.

First, to be able to retrieve sensitive data about projects, you will need the access token. The access token you can get from the user profile settings in Bitbucket site.

Powerful Token

There are some role with token specific to your needs : admin / read / write. In this example I’m using admin role.

  • Get all repositories in a project


PATH: https://{server_name}/rest/api/1.0/projects/{project_name}/repos

AUTHORIZATION: Bearer + {token}

  • Get commits in a repository


PATH: https://{server_name}/rest/api/1.0/projects/{project_name}/repos/{repo_name}/commits

AUTHORIZATION: Bearer + {token}

  • Get pull requests with current user

PATH: https://{server_name}/rest/api/1.0/dashboard/pull-requests

  • Create a new branch


PATH: https://{server_name}/rest/api/1.0/projects/{project_name}/repos/{repo_name}/branches



“name”: “testing”,

“startPoint”: “{from_which_commit_id}”,

“message”: “Create a new branch from Bitbucket API”


There are some more APIs that Bitbucket supported. You can refer to for more details.

~~ Happy coding guys ~~

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store