The name of the commit/branch/tag. Default: the repository’s default branch (usually master
)
Get repository content
Gets the contents of a file or directory in a repository. Specify the file path or directory in :path
. If you omit
:path
, you will receive the contents of the repository’s root directory. See the description below regarding what the API response includes for directories.
Files and symlinks support a custom media type for
retrieving the raw content or rendered HTML (when supported). All content types support a custom media
type to ensure the content is returned in a consistent
object format.
Note:
- To get a repository’s contents recursively, you can recursively get the tree.
- This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the Git Trees
API. - This API supports files up to 1 megabyte in size.
If the content is a directory
The response will be an array of objects, one object for each item in the directory.
When listing the contents of a directory, submodules have their “type” specified as “file”. Logically, the value
should be “submodule”. This behavior exists in API v3 for backwards compatibility purposes.
In the next major version of the API, the type will be returned as “submodule”.
If the content is a symlink
If the requested :path
points to a symlink, and the symlink’s target is a normal file in the repository, then the
API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object
describing the symlink itself.
If the content is a submodule
The submodule_git_url
identifies the location of the submodule repository, and the sha
identifies a specific
commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out
the submodule at that specific commit.
If the submodule repository is not hosted on github.com, the Git URLs (git_url
and _links["git"]
) and the
github.com URLs (html_url
and _links["html"]
) will have null values.
Query Parameters
Path Parameters
path parameter
Response
Response
Response
Content Tree
Content Tree
Show Child Parameters
Show Child Parameters
Path Parameters
Query Parameters
Create or update file contents
Creates a new file or replaces an existing file in a repository.
Path Parameters
path parameter
Body
application/json
Body
The commit message.
The new file content, using Base64 encoding.
Required if you are updating a file. The blob SHA of the file being replaced.
The branch name. Default: the repository’s default branch (usually master
)
The person that committed the file. Default: the authenticated user.
Show Child Parameters
The author of the file. Default: The committer
or the authenticated user if you omit committer
.
Show Child Parameters
Response
application/json
Response
Response
File Commit
File Commit
Show Child Parameters
Show Child Parameters
Path Parameters
Body
Delete a file
Deletes 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.
Path Parameters
path parameter
Body
application/json
Body
The commit message.
The blob SHA of the file being replaced.
The branch name. Default: the repository’s default branch (usually master
)
object containing information about the committer.
Show Child Parameters
object containing information about the author.
Show Child Parameters
Response
application/json
Response
Response
File Commit
File Commit
Show Child Parameters
Show Child Parameters
Path Parameters
Body
List repository contributors
Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API v3 caches contributor data to improve performance.
GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.
Query Parameters
Set to 1
or true
to include anonymous contributors in results.
Results per page (max 100)
Default:30
Page number of the results to fetch.
Default:1
Path Parameters
Response
application/json
Response
if repository contains content
Contributor
Path Parameters
Query Parameters
List deployments
Simple filtering of deployments is available via query parameters:
Query Parameters
The SHA recorded at creation time.
Default:none
The name of the ref. This can be a branch, tag, or SHA.
Default:none
The name of the task for the deployment (e.g., deploy
or deploy:migrations
).
Default:none
The name of the environment that was deployed to (e.g., staging
or production
).
Default:none
Results per page (max 100)
Default:30
Page number of the results to fetch.
Default:1
Path Parameters
Response
200 application/json
Response
Response
A request for a specific ref(branch,sha,tag) to be deployed
Example:https://api.github.com/repos/octocat/example/deployments/1
Unique identifier of the deployment
Example:42
Example:MDEwOkRlcGxveW1lbnQx
Example:a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d
The ref to deploy. This can be a branch, tag, or sha.
Example:topic-branch
Parameter to specify a task to execute
Example:deploy
One Of
Example:staging
Name for the target deployment environment.
Example:production
Example:Deploy request from hubot
Simple User
Show Child Parameters
Example:2012-07-20T01:19:13Z
Example:2012-07-20T01:19:13Z
Example:https://api.github.com/repos/octocat/example/deployments/1/statuses
Example:https://api.github.com/repos/octocat/example
Specifies if the given environment is will no longer exist at some point in the future. Default: false.
Example:true
Specifies if the given environment is one that end-users directly interact with. Default: false.
Example:true
GitHub apps are a new way to extend GitHub. They can be installed directly on organizations and user accounts and granted access to specific repositories. They come with granular permissions and built-in webhooks. GitHub apps are first class actors within GitHub.