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

Create a dashboard listing pull requests with more than a specified number of lines

Hi Bitbucket community,


We need to create a dashboard with all pull requests that are bigger than a specified limit on the number of lines. Or all pull requests with the number of lines changed.


This could be a dashboard on bitbucket, data exported to google sheets, or a script run on the command line to create a local csv.


Please suggest the best possible way to go about this. We can write code if required.




1 answer

0 votes

Hi @Rajesh Magham,

I believe that this should be possible if you write a script using our API.

If you are interested in pull requests of all repositories in a workspace, the first step would be to get all repositories of this workspace with the following endpoint:

Then, for each repository you can get its pull requests with the following endpoint:

Please note that by default, this endpoint returns only OPEN pull requests (this is also mentioned in the link above).
If you are interested in pull requests that are also MERGED or DECLINED, you will need to run additional queries to get pull requests in these states as well.
An example with curl to get pull requests in MEGRGED state:

curl -u <username>:<app-password><workspace-id>/<repo-slug>/pullrequests?q=state+%3D+%22MERGED%22

When you have the list of pull requests, you can use the following endpoint for each pull request to get its diffstat:

An example call with curl would be the following (for a PR with id 2):

curl -u <username>:<app-password> -L<workspace-id>/<repo-slug>/pullrequests/2/diffstat

Please note that the -L parameter is needed in the call because this endpoint redirects to the repository diffstat.

The output of this call has the fields lines_removed and lines_added for each file of the pull request.
You will need to add these values for each file of the PR, in order to get the total number of lines of the PR's diff.

By default, each endpoint returns all the fields available for a resource, and that can be a lot of data.
You can use the fields parameter in the API calls, in order to return only the fields that are useful to you.
You can read more about that and find examples here:

If you have any questions, please feel free to let me know.

Kind regards,

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events