Skip to main content

files

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

Overview

Namefiles
TypeResource
Idgithub.pulls.files

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
additionsinteger
blob_urlstring (uri) (example: https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt)
changesinteger
contents_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e)
deletionsinteger
filenamestring (example: file1.txt)
patchstring (example: @@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test)
previous_filenamestring (example: file.txt)
raw_urlstring (uri) (example: https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt)
shastring (example: bbcd538c8e72b8c175046e27cc8f907076331401)
statusstring (added, removed, modified, renamed, copied, changed, unchanged) (example: added)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_filesselectowner, repo, pull_numberper_page, pageLists the files in a specified pull request.

> [!NOTE]
> Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.

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.
pull_numberintegerThe number that identifies the pull request.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
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."

SELECT examples

Lists the files in a specified pull request.

> [!NOTE]
> Responses include a maximum of 3000 files. The paginated response returns 30 files per page by default.

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
additions,
blob_url,
changes,
contents_url,
deletions,
filename,
patch,
previous_filename,
raw_url,
sha,
status
FROM github.pulls.files
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND pull_number = '{{ pull_number }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;