GitHub v3 REST API

Create a review comment for a pull request

Creates a review comment in the pull request diff. To add a regular comment to a pull request timeline, see “Create an issue comment.” We recommend creating a review comment using line, side, and optionally start_line and start_side if your comment applies to more than one line in the pull request diff.

You can still create a review comment using the position parameter. When you use position, the line, side, start_line, and start_side parameters are not required. For more information, see the comfort-fade preview notice.

Note: The position value equals the number of lines down from the first “@@” hunk header in the file you want to add a comment. The line just below the “@@” line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. See “Secondary rate limits” and “Dealing with secondary rate limits” for details.

post
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/pulls/{pull_number}/comments

Path Parameters

ownerstringrequired
repostringrequired
pull_numberintegerrequired

Body

application/json
bodystringrequired

The text of the review comment.

commit_idstring

The SHA of the commit needing a comment. Not using the latest commit SHA may render your comment outdated if a subsequent commit modifies the line you specify as the position.

pathstring

The relative path to the file that necessitates a comment.

positioninteger

Required without comfort-fade preview. The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note above.

sidestring

Required with comfort-fade preview. In a split diff view, the side of the diff that the pull request’s changes appear on. Can be LEFT or RIGHT. Use LEFT for deletions that appear in red. Use RIGHT for additions that appear in green or unchanged lines that appear in white and are shown for context. For a multi-line comment, side represents whether the last line of the comment range is a deletion or addition. For more information, see “Diff view options” in the GitHub Help documentation.

Allowed values:LEFTRIGHT

lineinteger

Required with comfort-fade preview. The line of the blob in the pull request diff that the comment applies to. For a multi-line comment, the last line of the range that your comment applies to.

start_lineinteger

Required when using multi-line comments. To create multi-line comments, you must use the comfort-fade preview header. The start_line is the first line in the pull request diff that your multi-line comment applies to. To learn more about multi-line comments, see “Commenting on a pull request” in the GitHub Help documentation.

start_sidestring

Required when using multi-line comments. To create multi-line comments, you must use the comfort-fade preview header. The start_side is the starting side of the diff that the comment applies to. Can be LEFT or RIGHT. To learn more about multi-line comments, see “Commenting on a pull request” in the GitHub Help documentation. See side in this table for additional context.

Allowed values:LEFTRIGHTside

in_reply_tointeger

The ID of the review comment to reply to. To find the ID of a review comment with “List review comments on a pull request”. When specified, all parameters other than body in the request body are ignored.

Example:2

Response

application/json

Response

Pull Request Review Comment

Pull Request Review Comments are comments on a portion of the Pull Request’s diff.

urlstringrequired

URL for the pull request review comment

Example:https://api.github.com/repos/octocat/Hello-World/pulls/comments/1

pull_request_review_idinteger | nullrequired

The ID of the pull request review to which the comment belongs.

Example:42

idintegerrequired

The ID of the pull request review comment.

Example:1

node_idstringrequired

The node ID of the pull request review comment.

Example:MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw

diff_hunkstringrequired

The diff of the line that the comment refers to.

Example:@@ -16,33 +16,40 @@ public class Connection : IConnection...

pathstringrequired

The relative path of the file to which the comment applies.

Example:config/database.yaml

positionintegerrequired

The line index in the diff to which the comment applies.

Example:1

original_positionintegerrequired

The index of the original line in the diff to which the comment applies.

Example:4

commit_idstringrequired

The SHA of the commit to which the comment applies.

Example:6dcb09b5b57875f334f61aebed695e2e4193db5e

original_commit_idstringrequired

The SHA of the original commit to which the comment applies.

Example:9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840

in_reply_to_idinteger

The comment ID to reply to.

Example:8

userobjectrequired

Simple User

Show Child Parameters
bodystringrequired

The text of the comment.

Example:We should probably include a check for null values here.

created_atstring(date-time)required

Example:2011-04-14T16:00:49Z

updated_atstring(date-time)required

Example:2011-04-14T16:00:49Z

html_urlstring(uri)required

HTML URL for the pull request review comment.

Example:https://github.com/octocat/Hello-World/pull/1#discussion-diff-1

pull_request_urlstring(uri)required

URL for the pull request that the review comment belongs to.

Example:https://api.github.com/repos/octocat/Hello-World/pulls/1

author_associationstringrequired

How the author is associated with the repository.

Allowed values:COLLABORATORCONTRIBUTORFIRST_TIMERFIRST_TIME_CONTRIBUTORMANNEQUINMEMBERNONEOWNER

Example:OWNER

_linksobjectrequired
Show Child Parameters
start_lineinteger | null

The first line of the range for a multi-line comment.

Example:2

original_start_lineinteger | null

The first line of the range for a multi-line comment.

Example:2

start_sidestring | null

The side of the first line of the range for a multi-line comment.

Allowed values:LEFTRIGHT

Default:RIGHT

lineinteger

The line of the blob to which the comment applies. The last line of the range for a multi-line comment

Example:2

original_lineinteger

The line of the blob to which the comment applies. The last line of the range for a multi-line comment

Example:2

sidestring

The side of the diff to which the comment applies. The side of the last line of the range for a multi-line comment

Allowed values:LEFTRIGHT

Default:RIGHT

reactionsobject
Show Child Parameters
body_htmlstring

Example:"<p>comment body</p>"

body_textstring

Example:"comment body"

post/repos/{owner}/{repo}/pulls/{pull_number}/comments

Body

{ "body": "Let's add this deleted line back.", "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e", "path": "file1.txt", "line": 5, "side": "LEFT" }
 
application/json

Create a reply for a review comment

Creates a reply to a review comment for a pull request. For the comment_id, provide the ID of the review comment you are replying to. This must be the ID of a top-level review comment, not a reply to that comment. Replies to replies are not supported.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. See “Secondary rate limits” and “Dealing with secondary rate limits” for details.

post
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies

Path Parameters

ownerstringrequired
repostringrequired
pull_numberintegerrequired
comment_idintegerrequired

comment_id parameter

Body

application/json
bodystringrequired

The text of the review comment.

Response

application/json

Response

Pull Request Review Comment

Pull Request Review Comments are comments on a portion of the Pull Request’s diff.

urlstringrequired

URL for the pull request review comment

Example:https://api.github.com/repos/octocat/Hello-World/pulls/comments/1

pull_request_review_idinteger | nullrequired

The ID of the pull request review to which the comment belongs.

Example:42

idintegerrequired

The ID of the pull request review comment.

Example:1

node_idstringrequired

The node ID of the pull request review comment.

Example:MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDEw

diff_hunkstringrequired

The diff of the line that the comment refers to.

Example:@@ -16,33 +16,40 @@ public class Connection : IConnection...

pathstringrequired

The relative path of the file to which the comment applies.

Example:config/database.yaml

positionintegerrequired

The line index in the diff to which the comment applies.

Example:1

original_positionintegerrequired

The index of the original line in the diff to which the comment applies.

Example:4

commit_idstringrequired

The SHA of the commit to which the comment applies.

Example:6dcb09b5b57875f334f61aebed695e2e4193db5e

original_commit_idstringrequired

The SHA of the original commit to which the comment applies.

Example:9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840

in_reply_to_idinteger

The comment ID to reply to.

Example:8

userobjectrequired

Simple User

Show Child Parameters
bodystringrequired

The text of the comment.

Example:We should probably include a check for null values here.

created_atstring(date-time)required

Example:2011-04-14T16:00:49Z

updated_atstring(date-time)required

Example:2011-04-14T16:00:49Z

html_urlstring(uri)required

HTML URL for the pull request review comment.

Example:https://github.com/octocat/Hello-World/pull/1#discussion-diff-1

pull_request_urlstring(uri)required

URL for the pull request that the review comment belongs to.

Example:https://api.github.com/repos/octocat/Hello-World/pulls/1

author_associationstringrequired

How the author is associated with the repository.

Allowed values:COLLABORATORCONTRIBUTORFIRST_TIMERFIRST_TIME_CONTRIBUTORMANNEQUINMEMBERNONEOWNER

Example:OWNER

_linksobjectrequired
Show Child Parameters
start_lineinteger | null

The first line of the range for a multi-line comment.

Example:2

original_start_lineinteger | null

The first line of the range for a multi-line comment.

Example:2

start_sidestring | null

The side of the first line of the range for a multi-line comment.

Allowed values:LEFTRIGHT

Default:RIGHT

lineinteger

The line of the blob to which the comment applies. The last line of the range for a multi-line comment

Example:2

original_lineinteger

The line of the blob to which the comment applies. The last line of the range for a multi-line comment

Example:2

sidestring

The side of the diff to which the comment applies. The side of the last line of the range for a multi-line comment

Allowed values:LEFTRIGHT

Default:RIGHT

reactionsobject
Show Child Parameters
body_htmlstring

Example:"<p>comment body</p>"

body_textstring

Example:"comment body"

post/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies

Body

{ "body": "Great stuff!" }
 
application/json

List commits on a pull request

Lists a maximum of 250 commits for a pull request. To receive a complete commit list for pull requests with more than 250 commits, use the List commits endpoint.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/pulls/{pull_number}/commits

Query Parameters

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Path Parameters

ownerstringrequired
repostringrequired
pull_numberintegerrequired

Response

200 application/json

Response

Commit

urlstring(uri)required

Example:https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e

shastringrequired

Example:6dcb09b5b57875f334f61aebed695e2e4193db5e

node_idstringrequired

Example:MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==

html_urlstring(uri)required

Example:https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e

comments_urlstring(uri)required

Example:https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments

commitobjectrequired
Show Child Parameters
authorobject | nullrequired

Simple User

Show Child Parameters
committerobject | nullrequired

Simple User

Show Child Parameters
parentsarray[object]required
Show Child Parameters
statsobject
Show Child Parameters
filesarray[object]

Diff Entry

Show Child Parameters
get/repos/{owner}/{repo}/pulls/{pull_number}/commits
 
200 application/json

List pull requests files

Note: Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/pulls/{pull_number}/files

Query Parameters

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Path Parameters

ownerstringrequired
repostringrequired
pull_numberintegerrequired

Response

application/json

Response

Diff Entry

shastringrequired

Example:bbcd538c8e72b8c175046e27cc8f907076331401

filenamestringrequired

Example:file1.txt

statusstringrequired

Allowed values:addedremovedmodifiedrenamedcopiedchangedunchanged

Example:added

additionsintegerrequired

Example:103

deletionsintegerrequired

Example:21

changesintegerrequired

Example:124

blob_urlstring(uri)required

Example:https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt

raw_urlstring(uri)required

Example:https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt

contents_urlstring(uri)required

Example:https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e

patchstring

Example:@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test

previous_filenamestring

Example:file.txt

get/repos/{owner}/{repo}/pulls/{pull_number}/files
 
application/json

Check if a pull request has been merged

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/pulls/{pull_number}/merge

Path Parameters

ownerstringrequired
repostringrequired
pull_numberintegerrequired

Response

Response if pull request has been merged

get/repos/{owner}/{repo}/pulls/{pull_number}/merge