Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get "my pull requests" from github api?

Tags:

If you look at: http://developer.github.com/v3/pulls/ it shows you how to get pull requests for a given repository.

How do we get "my pull requests" from the GitHub API similar to the data displayed on the GitHub dashboard?

I need something like this

like image 216
Nicholas DiPiazza Avatar asked Jul 01 '13 20:07

Nicholas DiPiazza


People also ask

How do I access pull requests?

To accept the pull request, click the Pull Requests tab to see a summary of pending pull requests. If you are happy with the changes, click Merge Pull request to accept the pull request and perform the merge. You can add in a comment if you want. Once you click Merge Pull request, you will see a button Confirm merge.

How do I find pull request URL?

To create a pull request using a web browser (bitbucket web interface), go to the branch web page of your branch, or the branches page of your bitbucket repo. We can go to https://bitbucket.org/my-company/repo/branch/my-branch , there is a "Create pull request" link.


2 Answers

I asked Github directly. A rep told me to use the search endpoint. Search for issues owned by you that are open and of type pr.

https://api.github.com/search/issues?q=state%3Aopen+author%3Adavidxia+type%3Apr

If you're using a python client lib like Pygithub you can do

issues = gh.search_issues('', state='open', author='davidxia', type='pr')
like image 160
David Xia Avatar answered Sep 18 '22 15:09

David Xia


You can also use GraphQL API v4 to get all your pull requests :

{
  user(login: "bertrandmartel") {
    pullRequests(first: 100, states: OPEN) {
      totalCount
      nodes {
        createdAt
        number
        title
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}

Try it in the explorer

or using viewer :

{
  viewer {
    pullRequests(first: 100, states: OPEN) {
      totalCount
      nodes {
        createdAt
        number
        title
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
like image 22
Bertrand Martel Avatar answered Sep 18 '22 15:09

Bertrand Martel