简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM