Skip to main content

pull_requests

Creates, updates, deletes, gets or lists a pull_requests resource.

Overview

Namepull_requests
TypeResource
Idgithub.pulls.pull_requests

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idinteger (int64)
node_idstring (example: MDExOlB1bGxSZXF1ZXN0MQ==)
_linksobject
active_lock_reasonstring (example: too heated)
assigneeobjectA GitHub user. (title: Simple User)
assigneesarray
author_associationstringHow the author is associated with the repository. (COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNER) (title: author_association, example: OWNER)
auto_mergeobjectThe status of auto merging a pull request. (title: Auto merge)
baseobject
bodystring (example: Please pull these awesome changes)
closed_atstring (date-time) (example: 2011-01-26T19:01:12Z)
comments_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/issues/1347/comments)
commits_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347/commits)
created_atstring (date-time) (example: 2011-01-26T19:01:12Z)
diff_urlstring (uri) (example: https://github.com/octocat/Hello-World/pull/1347.diff)
draftbooleanIndicates whether or not the pull request is a draft.
headobject
html_urlstring (uri) (example: https://github.com/octocat/Hello-World/pull/1347)
issue_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/issues/1347)
labelsarray
lockedboolean
merge_commit_shastring (example: e5bd3914e2e596debea16f433f57875b5b90bcd6)
merged_atstring (date-time) (example: 2011-01-26T19:01:12Z)
milestoneobjectA collection of related issues and pull requests. (title: Milestone)
numberinteger
patch_urlstring (uri) (example: https://github.com/octocat/Hello-World/pull/1347.patch)
requested_reviewersarray
requested_teamsarray
review_comment_urlstring (example: https://api.github.com/repos/octocat/Hello-World/pulls/comments{/number})
review_comments_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347/comments)
statestring (example: open)
statuses_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e)
titlestring (example: new-feature)
updated_atstring (date-time) (example: 2011-01-26T19:01:12Z)
urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/pulls/1347)
userobjectA GitHub user. (title: Simple User)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectowner, repostate, head, base, sort, direction, per_page, pageLists pull requests in a specified repository.

Draft pull requests are available in public repositories with GitHub
Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing
plans, and in public and private repositories with GitHub Team and GitHub Enterprise
Cloud. For more information, see GitHub's products
in the GitHub Help documentation.

This endpoint supports the following custom media types. For more information, see "Media types."

- application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
basestringFilter pulls by base branch name. Example: gh-pages.
directionstringThe direction of the sort. Default: desc when sort is created or sort is not specified, otherwise asc.
headstringFilter pulls by head user or head organization and branch name in the format of user:ref-name or organization:ref-name. For example: github:new-script-format or octocat:test-branch.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
sortstringWhat to sort results by. popularity will sort by the number of comments. long-running will sort by date created and will limit the results to pull requests that have been open for more than a month and have had activity within the past month.
statestringEither open, closed, or all to filter by state.

SELECT examples

Lists pull requests in a specified repository.

Draft pull requests are available in public repositories with GitHub
Free and GitHub Free for organizations, GitHub Pro, and legacy per-repository billing
plans, and in public and private repositories with GitHub Team and GitHub Enterprise
Cloud. For more information, see GitHub's products
in the GitHub Help documentation.

This endpoint supports the following custom media types. For more information, see "Media types."

- application/vnd.github.raw+json: Returns the raw markdown body. Response will include body. This is the default if you do not pass any specific media type.
- application/vnd.github.text+json: Returns a text only representation of the markdown body. Response will include body_text.
- application/vnd.github.html+json: Returns HTML rendered from the body's markdown. Response will include body_html.
- application/vnd.github.full+json: Returns raw, text, and HTML representations. Response will include body, body_text, and body_html.

SELECT
id,
node_id,
_links,
active_lock_reason,
assignee,
assignees,
author_association,
auto_merge,
base,
body,
closed_at,
comments_url,
commits_url,
created_at,
diff_url,
draft,
head,
html_url,
issue_url,
labels,
locked,
merge_commit_sha,
merged_at,
milestone,
number,
patch_url,
requested_reviewers,
requested_teams,
review_comment_url,
review_comments_url,
state,
statuses_url,
title,
updated_at,
url,
user
FROM github.pulls.pull_requests
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND state = '{{ state }}'
AND head = '{{ head }}'
AND base = '{{ base }}'
AND sort = '{{ sort }}'
AND direction = '{{ direction }}'
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;