GitHub v3 REST API

Create a tree

The tree creation API accepts nested entries. If you specify both a tree and a nested path modifying that tree, this endpoint will overwrite the contents of the tree with the new path contents, and create a new tree structure.

If you use this endpoint to add, delete, or modify the file contents in a tree, you will need to commit the tree and then update a branch to point to the commit. For more information see “Create a commit” and “Update a reference.”

post
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/git/trees

Path Parameters

ownerstringrequired
repostringrequired

Body

application/json
treearray[object]required

Objects (of path, mode, type, and sha) specifying a tree structure.

Show Child Parameters
base_treestring

The SHA1 of an existing Git tree object which will be used as the base for the new tree. If provided, a new Git tree object will be created from entries in the Git tree object pointed to by base_tree and entries defined in the tree parameter. Entries defined in the tree parameter will overwrite items from base_tree with the same path. If you’re creating new changes on a branch, then normally you’d set base_tree to the SHA1 of the Git tree object of the current latest commit on the branch you’re working on.
If not provided, GitHub will create a new Git tree object from only the entries defined in the tree parameter. If you create a new commit pointing to such a tree, then all files which were a part of the parent commit’s tree and were not defined in the tree parameter will be listed as deleted by the new commit.

Response

application/json

Response

Git Tree

The hierarchy between files in a Git repository.

shastringrequired
urlstring(uri)required
truncatedbooleanrequired
treearray[object]required

Objects specifying a tree structure

Example:[{"path":"file.rb","mode":"100644","type":"blob","size":30,"sha":"44b4fc6d56897b048c772eb4087f854f46256132","url":"https://api.github.com/repos/octocat/Hello-World/git/blobs/44b4fc6d56897b048c772eb4087f854f46256132","properties":{"path":{"type":"string"},"mode":{"type":"string"},"type":{"type":"string"},"size":{"type":"integer"},"sha":{"type":"string"},"url":{"type":"string"}},"required":["path","mode","type","sha","url","size"]}]

Show Child Parameters
post/repos/{owner}/{repo}/git/trees

Body

{ "base_tree": "9fb037999f264ba9a7fc6274d15fa3ae2ab98312", "tree": [ { "path": "file.rb", "mode": "100644", "type": "blob", "sha": "44b4fc6d56897b048c772eb4087f854f46256132" } ] }
 
application/json

Get a tree

Returns a single tree using the SHA1 value for that tree.

If truncated is true in the response then the number of items in the tree array exceeded our maximum limit. If you need to fetch more items, use the non-recursive method of fetching trees, and fetch one sub-tree at a time.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/git/trees/{tree_sha}

Query Parameters

recursivestring

Setting this parameter to any value returns the objects or subtrees referenced by the tree specified in :tree_sha. For example, setting recursive to any of the following will enable returning objects or subtrees: 0, 1, "true", and "false". Omit this parameter to prevent recursively returning objects or subtrees.

Path Parameters

ownerstringrequired
repostringrequired
tree_shastringrequired

Response

application/json

Response

Git Tree

The hierarchy between files in a Git repository.

shastringrequired
urlstring(uri)required
truncatedbooleanrequired
treearray[object]required

Objects specifying a tree structure

Example:[{"path":"file.rb","mode":"100644","type":"blob","size":30,"sha":"44b4fc6d56897b048c772eb4087f854f46256132","url":"https://api.github.com/repos/octocat/Hello-World/git/blobs/44b4fc6d56897b048c772eb4087f854f46256132","properties":{"path":{"type":"string"},"mode":{"type":"string"},"type":{"type":"string"},"size":{"type":"integer"},"sha":{"type":"string"},"url":{"type":"string"}},"required":["path","mode","type","sha","url","size"]}]

Show Child Parameters
get/repos/{owner}/{repo}/git/trees/{tree_sha}
 
application/json

Get all gitignore templates

List all templates available to pass as an option when creating a repository.

get
{protocol}://{hostname}/api/v3/gitignore/templates

Response

application/json

Response

array[string]
get/gitignore/templates
 
application/json

Get a gitignore template

The API also allows fetching the source of a single template.
Use the raw media type to get the raw contents.

get
{protocol}://{hostname}/api/v3/gitignore/templates/{name}

Path Parameters

namestringrequired

Response

application/json

Response

Gitignore Template

Gitignore Template

namestringrequired

Example:C

sourcestringrequired

Example:# Object files *.o # Libraries *.lib *.a # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app

get/gitignore/templates/{name}
 
application/json

List issues assigned to the authenticated user

List issues assigned to the authenticated user across all visible repositories including owned repositories, member
repositories, and organization repositories. You can use the filter query parameter to fetch issues that are not
necessarily assigned to you.

Note: GitHub’s REST API v3 considers every pull request an issue, but not every issue is a pull request. For this
reason, “Issues” endpoints may return both issues and pull requests in the response. You can identify pull requests by
the pull_request key. Be aware that the id of a pull request returned from “Issues” endpoints will be an issue id. To find out the pull
request id, use the “List pull requests” endpoint.

get
{protocol}://{hostname}/api/v3/issues

Query Parameters

filterstring

Indicates which sorts of issues to return. Can be one of:
* assigned: Issues assigned to you
* created: Issues created by you
* mentioned: Issues mentioning you
* subscribed: Issues you’re subscribed to updates for
* all or repos: All issues the authenticated user can see, regardless of participation or creation

Allowed values:assignedcreatedmentionedsubscribedreposall

Default:assigned

statestring

Indicates the state of the issues to return. Can be either open, closed, or all.

Allowed values:openclosedall

Default:open

labelsstring

A list of comma separated label names. Example: bug,ui,@high

sortstring

What to sort results by. Can be either created, updated, comments.

Allowed values:createdupdatedcomments

Default:created

directionstring

One of asc (ascending) or desc (descending).

Allowed values:ascdesc

Default:desc

sincestring(date-time)

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

collabboolean
orgsboolean
ownedboolean
pullsboolean
per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Response

application/json

Response

Issues are a great way to keep track of tasks, enhancements, and bugs for your projects.

idintegerrequired
node_idstringrequired
urlstring(uri)required

URL for the issue

Example:https://api.github.com/repositories/42/issues/1

repository_urlstring(uri)required
labels_urlstringrequired
comments_urlstring(uri)required
events_urlstring(uri)required
html_urlstring(uri)required
numberintegerrequired

Number uniquely identifying the issue within its repository

Example:42

statestringrequired

State of the issue; either ‘open’ or ‘closed’

Example:open

titlestringrequired

Title of the issue

Example:Widget creation fails in Safari on OS X 10.8

bodystring | null

Contents of the issue

Example:It looks like the new widget form is broken on Safari. When I try and create the widget, Safari crashes. This is reproducible on 10.8, but not 10.9. Maybe a browser bug?

userobject | nullrequired

Simple User

Show Child Parameters
labelsOne Of
arrayrequired

Labels to associate with this issue; pass one or more label names to replace the set of labels on this issue; send an empty array to clear all labels from the issue; note that the labels are silently dropped for users without push access to the repository

Example:["bug","registration"]

Variant 1string
assigneeobject | nullrequired

Simple User

Show Child Parameters
assigneesarray | null[object]

Simple User

Show Child Parameters
milestoneobject | nullrequired

A collection of related issues and pull requests.

Show Child Parameters
lockedbooleanrequired
active_lock_reasonstring | null
commentsintegerrequired
pull_requestobject
Show Child Parameters
closed_atstring | null(date-time)required
created_atstring(date-time)required
updated_atstring(date-time)required
draftboolean
closed_byobject | null

Simple User

Show Child Parameters
body_htmlstring
body_textstring
timeline_urlstring(uri)
repositoryobject

A git repository

Show Child Parameters
performed_via_github_appobject | null

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.

Show Child Parameters
author_associationstringrequired

How the author is associated with the repository.

Allowed values:COLLABORATORCONTRIBUTORFIRST_TIMERFIRST_TIME_CONTRIBUTORMANNEQUINMEMBERNONEOWNER

Example:OWNER

reactionsobject
Show Child Parameters
get/issues
 
application/json