Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get pull requests filter with owner using Github API

I just want to query the PRs from a specific user.

Do I need to use the head param? But how?

https://api.github.com/repos/org-a/repo-b/pulls?state=open&per_page=1&head=owner:user-c does not work.

API Refer: https://developer.github.com/v3/pulls/#list-pull-requests

like image 472
mitnk Avatar asked Nov 12 '14 04:11

mitnk


People also ask

How do I filter PR on GitHub?

Filter pull requests that someone has asked you directly to review: state:open type:pr user-review-requested:@me. Filter pull requests by the team requested for review: state:open type:pr team-review-requested:github/atom. Filter for pull requests that are linked to an issue that the pull request may close: linked: ...


2 Answers

Use the Search API and specify repo:REPO, author:USER and is:pr filters:

https://developer.github.com/v3/search/#search-issues-and-pull-requests

For example, here are the pull requests from rails/rails from aderyabin:

https://api.github.com/search/issues?q=is:pr+repo:rails/rails+author:aderyabin

like image 75
Ivan Zuzak Avatar answered Oct 14 '22 02:10

Ivan Zuzak


Here is the GraphQL API syntax to query the pull requests in the repo rails/rails from the author aderyabin:

{
  search(query: "is:pr author:aderyabin repo:rails/rails", type: ISSUE, first: 100) {
    issueCount
    edges {
      node {
        ... on PullRequest {
          title
          createdAt
          url
        }
      }
    }
  }
}

The PullRequest object docs lists the fields available to query.

It doesn't seem to be possible at the moment to filter a user's PR for a given repo (or a repo's PR for a given user), but the same result can be achieved with the search query above.

like image 35
Jelefra Avatar answered Oct 14 '22 02:10

Jelefra