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?
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.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With