GET/repos/{owner}/{repo}/contents/{path}

Get repository content

Retrieves a file or directory from a repository at the specified path. Use ref to select a commit, branch, or tag; it defaults to the repository's default branch when omitted. Directory responses are limited to 1,000 items, and files larger than 100 MB are not supported.

4 parameters
ownerstringrequired
The account that owns the repository; the name is not case-sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case-sensitive.
pathstringrequired
The path to the file or directory within the repository.
refstringoptional
The commit, branch, or tag to read from. Defaults to the repository's default branch when omitted.

5 status codes
200Returns the requested content as a file, directory listing, symlink description, or submodule entry, depending on the content at `path` and the requested media type.
typestringrequired
Allowed:dirfilesubmodulesymlink
sizeintegerrequired
namestringrequired
pathstringrequired
contentstringoptional
shastringrequired
urlstringrequired
git_urlstringrequired
html_urlstringrequired
download_urlstringrequired
_linksobjectrequired
302Returned when the request is redirected to another URL for the requested content.
304Returned when the content has not changed since the version indicated by the request's conditional headers.
403Returned when you do not have permission to access the repository contents.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the repository or requested content does not exist or cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional

Error handling

A 403 is returned when you do not have access to the repository contents. A 404 is returned when the repository or requested content cannot be found. The owner, repo, and path path parameters must identify the repository and the file or directory to retrieve.