Sample - GitHub REST API
GET/repos/{owner}/{repo}/contents/{path}

Get repository content

Retrieves a file, directory, symlink, or submodule from a repository. Supply the repository identifiers and the target path, with ref optionally selecting a commit, branch, or tag instead of the default branch. Directory responses are limited to 1,000 files, and files larger than 100 MB are not supported.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

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

5 status codes
200Returns the requested content as a file object, directory item array, symlink object, or submodule object, depending on the target and requested media type.
typestringrequired
Allowed:dirfilesubmodulesymlink
sizeintegerrequired
namestringrequired
pathstringrequired
contentstringoptional
shastringrequired
urlstringrequired
git_urlstringrequired
html_urlstringrequired
download_urlstringrequired
_linksobjectrequired
302Returned when the requested content is available at another location.
304Returned when the requested content has not changed.
403Returned when access to the repository content is forbidden.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the repository or requested content does not exist.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional

Error handling

A 403 is returned when access to the repository content is forbidden. A 404 is returned when the repository or requested content cannot be found. owner, repo, and path must identify the repository and content to retrieve; use ref to select a specific commit, branch, or tag.