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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Retrieve all open Pull Requests using API

The goal is to retrieve all open Pull Requests at the end of the day to notify users on slack.

1 answer

1 vote
seanaty Atlassian Team Jan 26, 2021

There is this API to GET all pull requests within a repository.

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pullrequests

By default, it only shows open pull requests so you don't have to do any filtering, however, if you wanted to, here are some capabilities of the Bitbucket API:

/2.0/repositories/bitbucket/bitbucket/pullrequests?q=state%3D"MERGED"%20or%20state%3D"OPEN"%20or%20state%3D"DECLINED"&fields=values.state,values.title&pagelen=50

 You can filter with the q parameter. After URL-decoding the value you see we are passing ing 'state="MERGED" or state="OPEN" or state="DECLINED"' as our filtering criteria. Here's more information on how it works. https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering (again, the default shows status=OPEN so you don't need this parameter.

The next parameter is `fields`. This let's you include/exclude/explicitly declare fields you'd like returned. Here I'm only returning the PR title and status for demonstration.

The final parameter, `pagelen` returns 50 results instead of the maximum of 10.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Posted in Bitbucket

Contest: Share your custom Bitbucket Pipe and win

Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...

2,140 views 11 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you