Get tree
Retrieve the directory structure (tree) of a repository at a specific path and reference.Parameters
The username or organization name that owns the repository
The repository name
The branch, tag, or commit reference to retrieve the tree from. Defaults to the default branch if not specified
The directory path to retrieve. Defaults to the repository root if not specified
Response
Returns an array of tree entries representing files and directories.Entry type:
tree for directories or blob for filesPath to the file or directory
Object ID (SHA-1 hash) of the tree or blob
Git file mode (e.g.,
100644 for regular files, 040000 for directories)Example request
Example response
Get blob
Retrieve the contents of a specific file (blob) from the repository.Parameters
The username or organization name that owns the repository
The repository name
The path to the file relative to the repository root
The branch, tag, or commit reference to retrieve the file from. Defaults to the default branch if not specified
Response
Returns an object containing the file content and metadata.Object ID (SHA-1 hash) of the blob
Base64-encoded file content
File size in bytes
Whether the file is detected as binary content
Syntax-highlighted HTML version of the file content. Only available for non-binary, non-markdown files. Uses the
github-dark-default themeExample request
Example response
Usage notes
- The
contentfield contains the raw file content encoded as Base64. Decode it to get the original file content - For text files, the
highlightedHtmlfield provides a ready-to-use syntax-highlighted HTML version using Shiki with thegithub-dark-defaulttheme - Markdown files (
.md,.mdx,.markdown) do not include syntax highlighting inhighlightedHtml - Binary files have
isBinaryset totrueandhighlightedHtmlset tonull - If a file is not found, the endpoint returns a 404 error