Access a Pull Request URL. Let's use https://api.github.com/repos/github/gitignore/pulls/566 as an example.
Parse the JSON object.
A Pull Request references two branches. The base branch is the merge target. Usually this is the master branch of the repository.
base.labelisgithub:master, meaning it's themasterbranch for >github/gitignore.base.refis the branch name "master".base.shais the current SHA of that branch.
The head branch is what you're merging into the base.
Answer from technoweenie on Stack Overflow
head.labelisfidelski:add-obvious-autotools-files, meaning it's theadd-obvious-autotools-filesbranch forfidelski/gitignore.head.refis the branch nameadd-obvious-autotools-files.head.shais the current SHA of that branch.
Videos
You can get all pull requests (closed, opened, merged) through the variable state.
Just set state=all in the GET query, like this->
https://api.github.com/repos/:owner/:repo/pulls?state=all
For more info: check the Parameters table at https://developer.github.com/v3/pulls/#list-pull-requests
Edit: As per Tomáš Votruba's comment:
the default value for, "per_page=30". The maximum is per_page=100. To get more than 100 results, you need to call it multiple itmes: "&page=1", "&page=2"...
PyGithub (https://github.com/PyGithub/PyGithub), a Python library to access the GitHub API v3, enables you to get paginated resources.
For example,
g = Github(login_or_token=$YOUR_TOKEN, per_page=100)
r = g.get_repo($REPO_NUMBER)
for pull in r.get_pulls('all'):
# You can access pulls
See the documentation (http://pygithub.readthedocs.io/en/latest/index.html).
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
}
}
}
}
I created a feature branch in the same repository against whom I wanted to create a Pull request. After that I invoked the api POST /repos/:owner/:repo/pulls as mentioned in the question with the following body:
{
"title": "Amazing new feature",
"body": "Please pull this in!",
"head": "feature",
"base": "master"
}
As you can see since my feature branch is in the same repo as the master against whom I am creating a Pull request I just mentioned it's name in the head.
After this I also ensured that I pass Authorization(Basic Auth ) and when I invoked the API the Pull request was created in the github.
Then I tried invoking the above API without passing the Authorization header and I got 404. Therefore I think you need to correct head value in the body as you mentioned in the comment that your branch is in the same repo as that of master against whom you are creating a Pull request. And make sure to pass the Authorization header
After using Basic Authentication as @Yug Sing suggest, then I can finally make the PR via API: my problem was that on the creation on the token for the basic auth, instead of using userName and accessToken, I used userName and my password of git, so the authentication fails