Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 853
Sunil Chaudhary Avatar asked Oct 19 '22 07:10

Sunil Chaudhary


2 Answers

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.
like image 148
VonC Avatar answered Oct 21 '22 14:10

VonC


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.

like image 25
Shouvik Mitra Avatar answered Oct 21 '22 16:10

Shouvik Mitra