| title | Repositories |
|---|
{:toc}
List repositories that are accessible to the authenticated user.
This includes repositories owned by the authenticated user, repositories where the authenticated user is a collaborator, and repositories that the authenticated user has access to through an organization membership.
GET /user/repos
| Name | Type | Description |
|---|---|---|
visibility |
string |
Can be one of all, public, or private. Default: all |
affiliation |
string |
Comma-separated list of values. Can include: * owner: Repositories that are owned by the authenticated user.* collaborator: Repositories that the user has been added to as a collaborator.* organization_member: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on.Default: owner,collaborator,organization_member |
type |
string |
Can be one of all, owner, public, private, member. Default: allWill cause a 422 error if used in the same request as visibility or affiliation. |
sort |
string |
Can be one of created, updated, pushed, full_name. Default: full_name |
direction |
string |
Can be one of asc or desc. Default: when using full_name: asc; otherwise desc |
List public repositories for the specified user.
GET /users/:username/repos
| Name | Type | Description |
|---|---|---|
type |
string |
Can be one of all, owner, member. Default: owner |
sort |
string |
Can be one of created, updated, pushed, full_name. Default: full_name |
direction |
string |
Can be one of asc or desc. Default: when using full_name: asc, otherwise desc |
List repositories for the specified org.
GET /orgs/:org/repos
| Name | Type | Description |
|---|---|---|
type |
string |
Can be one of all, public, private, forks, sources, member. Default: all |
<%= headers 200, :pagination => default_pagination_rels %> <%= json(:repo) { |h| [h] } %>
This provides a dump of every public repository, in the order that they were created.
Note: Pagination is powered exclusively by the since parameter.
Use the Link header to get the URL for the next page of
repositories.
{% if page.version != 'dotcom' and page.version >= 2.3 %}
If you are an authenticated site administrator for your Enterprise instance, you will be able to list all repositories including private repositories.
| Name | Type | Description |
|---|---|---|
visibility |
string |
To include private repositories as well set to all. Default: public |
{% endif %}
GET /repositories
| Name | Type | Description |
|---|---|---|
since |
string |
The integer ID of the last Repository that you've seen. |
<%= headers 200, :pagination => { :next => 'https://api.github.com/repositories?since=364' } %> <%= json(:simple_repo) { |h| [h] } %>
Create a new repository for the authenticated user.
POST /user/repos
Create a new repository in this organization. The authenticated user must be a member of the specified organization.
POST /orgs/:org/repos
When using OAuth, authorizations must include:
public_reposcope orreposcope to create a public repositoryreposcope to create a private repository
| Name | Type | Description |
|---|---|---|
name |
string |
Required. The name of the repository |
description |
string |
A short description of the repository |
homepage |
string |
A URL with more information about the repository |
private |
boolean |
Either true to create a private repository, or false to create a public one. Creating private repositories requires a paid GitHub account. Default: false |
has_issues |
boolean |
Either true to enable issues for this repository, false to disable them. Default: true |
has_wiki |
boolean |
Either true to enable the wiki for this repository, false to disable it. Default: true |
has_downloads |
boolean |
Either true to enable downloads for this repository, false to disable them. Default: true |
team_id |
integer |
The id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization. |
auto_init |
boolean |
Pass true to create an initial commit with empty README. Default: false |
gitignore_template |
string |
Desired language or platform .gitignore template to apply. Use the name of the template without the extension. For example, "Haskell". |
license_template |
string |
Desired LICENSE template to apply. Use the name of the template without the extension. For example, "mit" or "mozilla". |
<%= json
:name => "Hello-World",
:description => "This is your first repository",
:homepage => "https://github.com",
:private => false,
:has_issues => true,
:has_wiki => true,
:has_downloads => true
%>
<%= headers 201, :Location => get_resource(:repo)['url'] %> <%= json :repo %>
GET /repos/:owner/:repo
The parent and source objects are present when the repository is a fork.
parent is the repository this repository was forked from,
source is the ultimate source for the network.
<%= headers 200 %> <%= json :full_repo %>
PATCH /repos/:owner/:repo
| Name | Type | Description |
|---|---|---|
name |
string |
Required. The name of the repository |
description |
string |
A short description of the repository |
homepage |
string |
A URL with more information about the repository |
private |
boolean |
Either true to make the repository private, or false to make it public. Creating private repositories requires a paid GitHub account. Default: false |
has_issues |
boolean |
Either true to enable issues for this repository, false to disable them. Default: true |
has_wiki |
boolean |
Either true to enable the wiki for this repository, false to disable it. Default: true |
has_downloads |
boolean |
Either true to enable downloads for this repository, false to disable them. Default: true |
default_branch |
String |
Updates the default branch for this repository. |
<%= json
:name => "Hello-World",
:description => "This is your first repository",
:homepage => "https://github.com",
:private => true,
:has_issues => true,
:has_wiki => true,
:has_downloads => true
%>
<%= headers 200 %> <%= json :full_repo %>
List contributors to the specified repository, sorted by the number of commits per contributor in descending order.
{{#tip}}
Contributors data is cached for performance reasons. This endpoint may return information that is a few hours old.
Git contributors are identified by author email address. This API attempts to group contribution counts by GitHub user, across all of their associated email addresses. For performance reasons, only the first 500 author email addresses in the repository will be linked to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.
{{/tip}}
GET /repos/:owner/:repo/contributors
| Name | Type | Description |
|---|---|---|
anon |
string |
Set to 1 or true to include anonymous contributors in results. |
<%= headers 200, :pagination => default_pagination_rels %> <%= json(:contributor) { |h| [h] } %>
List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language.
GET /repos/:owner/:repo/languages
<%= headers 200 %>
<%= json
"C" => 78769,
"Python" => 7769
%>
GET /repos/:owner/:repo/teams
<%= headers 200, :pagination => default_pagination_rels %> <%= json(:team) { |h| [h] } %>
GET /repos/:owner/:repo/tags
<%= headers 200, :pagination => default_pagination_rels %> <%= json(:tag) { |h| [h] } %>
Deleting a repository requires admin access. If OAuth is used, the
delete_repo scope is required.
DELETE /repos/:owner/:repo
<%= headers 204 %>