How to Get Pull Request Data With REST API in Bitbucket Cloud
REST API is a vital tool for teams that value automation and custom reporting. That’s why we are excited to announce a new REST API that makes retrieving granular and aggregated pull request data from Bitbucket Cloud easy. In this article, we’ll walk you through what exact kind of data you can access and how to use new endpoints in the Awesome Graphs app.
Awesome Graphs is a top-rated data-providing and reporting app for Bitbucket that empowers teams around the globe with ready-to-use analytics on workspace, project, and repository levels as well as custom REST API solutions. This article covers the Cloud version of Awesome Graphs. If you’re using the Data Center version, refer to this tutorial on data export instead.
What pull request data you can get with REST API
The new Awesome Graphs REST API helps you easily access the following pull request attributes:
- Created date, closed date, and last updated date
- Title and ID of the pull request
- State
- Author details: ID and name
- Destination: repository and branch the PR is targeting
- Number of comments and tasks in each PR
With the new endpoints, it is also possible to retrieve aggregated pull request statistics.
This data can be used to build internal dashboards, generate custom reports, and power your workflows with more context on PR activity.
Retrieving pull request data with Awesome Graphs REST API
Let’s take a look at how the new REST API works and what steps you should follow to use it.
To access Awesome Graphs REST API, make sure that the app is installed in your instance and generate an API Access Token in Bitbucket Workspace settings.
Our endpoints allow you to retrieve pull request data on the level of the whole workspace,
curl --request GET
--url 'https://awesome-graphs.stiltsoft.net/rest/latest/workspace/{workspaceSlug}/pull-requests'
--header 'Authorization: {access_token}'
--header 'Accept: application/json'
on repository level,
curl --request GET
--url 'https://awesome-graphs.stiltsoft.net/rest/latest/workspace/{workspaceSlug}/repos/{repositorySlug}/pull-requests?state=merged&since_date=2025-05-30T00:00:00Z'
--header 'Authorization: {access_token}'
--header 'Accept: application/json'
and for individual users.
curl --request GET
--url 'https://awesome-graphs.stiltsoft.net/rest/latest/workspace/{workspaceSlug}/users/{user_uuid}/pull-requests?state=merged'
--header 'Authorization: {access_token}'
--header 'Accept: application/json'
Using parameters like since_date and until_date, you can easily control the time interval for which you would like to retrieve data. For the full list of available parameters, refer to our REST API documentation.
Here is an output example that you will get after running a query:
{
"values": [
{
"id": 108,
"title": "Release v2.3",
"state": "MERGED",
"closed": true,
"author": {
"displayName": "Jane Smith",
"uuid": "{75aaf68d-117a-4d99-8a46-0273fe4b1032}"
},
"destination": {
"branch": {
"name": "main"
},
"repository": {
"name": "awesome-repo"
}
},
"createdDate": "2024-10-08T08:33:11.595774+00:00",
"closedDate": "2024-10-10T11:52:07.637619+00:00",
"updatedDate": "2024-10-10T11:52:07.637619+00:00",
"commentCount": 6,
"taskCount": 6
}
]
"isLastPage": true,
"start": 102,
"size": 142,
"limit": 159
}
With unique attributes like comment and task count, you can easily analyse code review, while pull request state and creation/closure/update date can help you better understand the life cycles of pull requests.
Getting pull request statistics with REST API
If you are looking for a way to get aggregated pull request statistics, our new endpoints will catch your interest as well.
Here is the endpoint that will help you gather the statistics on a workspace level.
curl --request GET
--url 'https://awesome-graphs.stiltsoft.net/rest/latest/workspace/{workspaceSlug}/pull-requests/statistics'
--header 'Authorization: {access_token}'
--header 'Accept: application/json'
The same information can be gathered for a particular repository.
curl --request GET
--url 'https://awesome-graphs.stiltsoft.net/rest/latest/workspace/{workspaceSlug}/repos/{repositorySlug}/pull-requests/statistics'
--header 'Authorization: {access_token}'
--header 'Accept: application/json'
Last but not least, this endpoint provides statistical insight on the level of an individual user.
curl --request GET
--url 'https://awesome-graphs.stiltsoft.net/rest/latest/workspace/{workspaceSlug}/users/{user_uuid}/pull-requests/statistics'
--header 'Authorization: {access_token}'
--header 'Accept: application/json'
Refer to Awesome Graphs documentation to learn how to retrieve user_uuid to run the query.
The output for the pull request statistics query has the following format.
{
"pullRequests": 17,
"state": {
"declined": 5,
"merged": 7,
"open": 4,
"superseded": 1
}
}
It enables you to simplify your internal reporting systems by implementing already aggregated data.
Getting Started with Awesome Graphs REST API
To start using new endpoints:
- Make sure to activate your free Awesome Graphs trial for your Bitbucket Cloud workspace.
- Generate an authentication token in the app’s settings.
- Refer to the Awesome Graphs REST API documentation for the full list of parameters and response fields.
If you have any questions about Awesome Graphs REST API or would like to suggest an improvement, please feel free to reach out to our customer support portal. Your feedback helps us improve.