I would like to know if there is a way to get the branch name , commit ID , commit author , lines added , removed ,modified from one single endpoint in bitbucket ?
The only place to get the modification counts is the diffstat API: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/diffstat/%7Bspec%7D
That works on a range of commits so there isn't any commit metadata. If you'd like to look up author and commit info you can use either the branches API or the commits API.
Both of these APIs require you to have a branch name or commit ID already. Without those, how do you plan on identifying the changes you're trying to look at?
So there isn't 1 place to get all this information but you can probably get it all with 2 requests.
Hi @seanaty thanks for the response really appreciate it. I have one follow up question that if we use branches end point it does give a commit hash in the response but that commit id is only the latest commit done to that branch is there a way to get all the commits done in one branch exclusively . I would like to know how to use the REST API 2.0 to achieve this . Currently I am calling the branches endpoint and from that I calling the link to commits to get all the commits. But this is proving to be tedious also as downward merge happens in my organization the commits from this path gets duplicated . I woul like some further assistance . Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can look up the diff (or diffstat) for any range of commits. If you're doing this for a PR there are some nifty PR APIs which will end up issuing an HTTP Redirect to the corresponding diff or diffstat API.
Pull request Diff:
Pull request Diff stat:
As an example,
https://api.bitbucket.org/2.0/repositories/atlassian/bbql/pullrequests/28/diffstat
will issue a redirect to:
which is the API for diffstat with `opensrckenh/bbql:642188fb450b%0D36a8e140e5ec` as the "spec" param.1
If you look at this it has the pattern
{branch}:{commit on the branch}%0D{commit defaults to main branch}
This is how you can use both diff and diff stat to look up ranges.
You can do a similar thing with the commits API. This is from the docs:
GET /repositories/{workspace}/{repo_slug}/commits/dev?exclude=master
Returns all commits on ref dev, except those that are reachable on master (similar to git log dev ^master).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.