Skip to main content

contents

Overview

Namecontents
TypeResource
Idgithub.repos.contents

Fields

NameDatatype
namestring
_linksobject
contentstring
download_urlstring
encodingstring
git_urlstring
html_urlstring
pathstring
shastring
sizeinteger
submodule_git_urlstring
targetstring
typestring
urlstring

Methods

NameAccessible byRequired ParamsDescription
get_readmeSELECTowner, repoGets the preferred README for a repository.

READMEs support custom media types for retrieving the raw content or rendered HTML.
get_readme_in_directorySELECTdir, owner, repoGets the README from a repository directory.

READMEs support custom media types for retrieving the raw content or rendered HTML.
create_or_update_file_contentsINSERTowner, path, repo, data__content, data__messageCreates a new file or replaces an existing file in a repository. You must authenticate using an access token with the repo scope to use this endpoint. If you want to modify files in the .github/workflows directory, you must authenticate using an access token with the workflow scope.

Note: If you use this endpoint and the "Delete a file" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
delete_fileDELETEowner, path, repo, data__message, data__shaDeletes a file in a repository.

You can provide an additional committer parameter, which is an object containing information about the committer. Or, you can provide an author parameter, which is an object containing information about the author.

The author section is optional and is filled in with the committer information if omitted. If the committer information is omitted, the authenticated user's information is used.

You must provide values for both name and email, whether you choose to use author or committer. Otherwise, you'll receive a 422 status code.

Note: If you use this endpoint and the "Create or update file contents" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
download_tarball_archiveEXECowner, ref, repoGets a redirect URL to download a tar archive for a repository. If you omit :ref, the repository’s default branch (usually
main) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use
the Location header to make a second GET request.
Note: For private repositories, these links are temporary and expire after five minutes.
download_zipball_archiveEXECowner, ref, repoGets a redirect URL to download a zip archive for a repository. If you omit :ref, the repository’s default branch (usually
main) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use
the Location header to make a second GET request.

Note: For private repositories, these links are temporary and expire after five minutes. If the repository is empty, you will receive a 404 when you follow the redirect.