| title | Repositories | GitHub API |
|---|
- TOC {:toc}
List repositories for the authenticated user.
Note that this currently does not include repositories owned by organizations which the user can access. You can list your organizations and list organization repositories separately.
With the new Organization Permissions API (described below), this will include repositories owned by organizations which the user can access. If you provide the custom media type (described below), you won't need to use other APIs to list the authenticated user's organization-owned repositories.
We're currently offering a migration period allowing applications to opt in to the Organization Permissions API. This functionality will soon apply to all API consumers. Please see the blog post for full details.
To access the API during the migration period, you must provide a custom media type in the Accept header:
application/vnd.github.moondragon+json
GET /user/repos
| Name | Type | Description |
|---|---|---|
type |
string |
Can be one of all, owner, public, private, member. Default: all |
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.
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 |
number |
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.
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] } %>
GET /repos/:owner/:repo/branches
<%= headers 200, :pagination => default_pagination_rels %> <%= json(:branches) %>
GET /repos/:owner/:repo/branches/:branch
<%= headers 200 %> <%= json(:branch) %>
Deleting a repository requires admin access. If OAuth is used, the
delete_repo scope is required.
DELETE /repos/:owner/:repo
<%= headers 204 %>