Search code examples
postmangithub-api

Pull all pull reviews in github api


I want to be able to pull all github pull reviews via the api. At the moment you can only GET a review via a specific number as per the below

GET /repos/:owner/:repo/pulls/:pull_number/reviews 

Is there a way that instead of just 1 pull_number i can pull through all pull reviews?

Im using Postman for the requests.


Solution

  • You can use GraphQL API v4 iterating over the pull requests and getting reviews list for each one. But it would give you a bunch of issues that have no reviews, so you would need to use the Github Search API to filter only issues of type PR that have been reviewed :

    https://api.github.com/search/issues?q=repo:mui-org/material-ui%20type:pr%20-review:none

    Using GraphQL v4 you can get the reviews easily :

    {
      search(type: ISSUE, query: "repo:mui-org/material-ui type:pr -review:none", first: 100) {
        issueCount
        nodes {
          ... on PullRequest {
            number
            reviews(first: 100) {
              nodes {
                author {
                  login
                }
                bodyText
                state
                createdAt
              }
            }
          }
        }
      }
    }