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

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')

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
      }
    }
  }
}

First you have to realize that you must authenticate using either Basic Authentication or a token. Next you have to realize that there is no simple way to do this so you will have to be clever.

To be specific, if you probe https://api.github.com/issues, you'll notice that the issues there have a hash called pull_request which should have 3 URLs: html, diff, and patch. All three will be non-null if the issue is also a Pull Request. (Pro-tip: They're the same thing as far as GitHub is concerned…sort of.)

If you iterate over your issues and filter for ones where those attributes are not null, then you'll have your pull requests.

Tags:

Github Api