Sunil Chaudhary
Sunil Chaudhary

Reputation: 4743

Is it possible to get all the pull requests made by a user on different repos using some API?

I am making an application where I need to get all the pull requests made by a particular user on various repositories.

I can get all the pull request on a particular repository but found no suitable API to get all the pull request by a user.

What kind of API call can I make to get those PR filtered by author?

Upvotes: 5

Views: 3433

Answers (2)

Shouvik Mitra
Shouvik Mitra

Reputation: 59

Try using the following code

var d=2018-09-30T10%3A00%3A00%2B00%3A00   //start date
var f=2018-11-01T12%3A00%3A00%2B00%3A00   //end date
var t=iamshouvikmitra                     //username


$.getJSON("https://api.github.com/search/issues?q=-label:invalid+created:" + d + ".." + f + "+type:pr+is:public+author:" + t + "&per_page=300", function(e) {


}

Infact this is similar to the code that https://hacktoberfest.digitalocean.com Uses to count the number of pull request you have submitted during the month of october.

Upvotes: 1

VonC
VonC

Reputation: 1324278

The List Pull Request API has a head filter:

head string

Filter pulls by head user and branch name in the format of user:ref-name.

Example: github:new-script-format.

That wouldn't work in your case, as you don't know the branch names, only the author.

Use instead the search API for issues

GET /search/issues

It can filter by:

  • type: With this qualifier you can restrict the search to issues (issue) or pull request (pr) only.
  • author: Finds issues or pull requests created by a certain user.

Upvotes: 2

Related Questions