Authentication
You can read public gists anonymously, but you must be signed into GitHub to create gists. To read or write gists on a user's behalf, you need the gist OAuth scope and a token. For more information, see "Scopes for OAuth Apps."
Truncation
The Gist API provides up to one megabyte of content for each file in the gist. Each file returned for a gist through the API has a key called truncated. If truncated is true, the file is too large and only a portion of the contents were returned in content.
If you need the full contents of the file, you can make a GET request to the URL specified by raw_url. Be aware that for files larger than ten megabytes, you'll need to clone the gist via the URL provided by git_pull_url.
In addition to a specific file's contents being truncated, the entire files list may be truncated if the total number exceeds 300 files. If the top level truncated key is true, only the first 300 files have been returned in the files list. If you need to fetch all of the gist's files, you'll need to clone the gist via the URL provided by git_pull_url.
Custom media types for gists
These are the supported media types for fetching gist contents.
application/vnd.github.VERSION.raw
application/vnd.github.VERSION.base64
For more information, see "Media types."
List gists for the authenticated user
Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists:
get /gistsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
since | string | query | Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists await octokit.request('GET /gists')Response
Status: 200 OK [
{
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"files": {
"hello_world.rb": {
"filename": "hello_world.rb",
"type": "application/x-ruby",
"language": "Ruby",
"raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
"size": 167
}
},
"public": true,
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"truncated": false
}
]Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenCreate a gist
Allows you to add a new gist with one or more files.
Note: Don't name your files "gistfile" with a numerical suffix. This is the format of the automatic naming scheme that Gist uses internally.
post /gistsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
description | string | body | Description of the gist |
files | object | body | Required. Names and content for the files that make up the gist |
public | boolean or string or | body | Flag indicating whether the gist is public |
Code samples
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists \
-d '{"files":{}}' await octokit.request('POST /gists', {
files: {}
})Response
Status: 201 Created {
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundValidation failed
Status: 422 Unprocessable EntityList public gists
List public gists sorted by most recently updated to least recently updated.
Note: With pagination, you can fetch up to 3000 gists. For example, you can fetch 100 pages with 30 gists per page or 30 pages with 100 gists per page.
get /gists/publicParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
since | string | query | Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/public await octokit.request('GET /gists/public')Response
Status: 200 OK [
{
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"files": {
"hello_world.rb": {
"filename": "hello_world.rb",
"type": "application/x-ruby",
"language": "Ruby",
"raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
"size": 167
}
},
"public": true,
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"truncated": false
}
]Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenValidation failed
Status: 422 Unprocessable EntityList starred gists
List the authenticated user's starred gists:
get /gists/starredParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
since | string | query | Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/starred await octokit.request('GET /gists/starred')Response
Status: 200 OK [
{
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"files": {
"hello_world.rb": {
"filename": "hello_world.rb",
"type": "application/x-ruby",
"language": "Ruby",
"raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
"size": 167
}
},
"public": true,
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"truncated": false
}
]Not modified
Status: 304 Not ModifiedRequires authentication
Status: 401 UnauthorizedForbidden
Status: 403 ForbiddenGet a gist
get /gists/{gist_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID await octokit.request('GET /gists/{gist_id}', {
gist_id: 'gist_id'
})Response
Status: 200 OK {
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}Not modified
Status: 304 Not ModifiedForbidden Gist
Status: 403 ForbiddenResource not found
Status: 404 Not FoundUpdate a gist
Allows you to update or delete a gist file and rename gist files. Files from the previous version of the gist that aren't explicitly changed during an edit are unchanged.
patch /gists/{gist_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
description | string | body | Description of the gist |
files | object | body | Names of files to be updated |
Code samples
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID \
-d '{"description":"description"}' await octokit.request('PATCH /gists/{gist_id}', {
gist_id: 'gist_id',
description: 'description'
})Response
Status: 200 OK {
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}Resource not found
Status: 404 Not FoundValidation failed
Status: 422 Unprocessable EntityDelete a gist
delete /gists/{gist_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
Code samples
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID await octokit.request('DELETE /gists/{gist_id}', {
gist_id: 'gist_id'
})Response
Status: 204 No ContentNot modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundList gist commits
get /gists/{gist_id}/commitsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/commits await octokit.request('GET /gists/{gist_id}/commits', {
gist_id: 'gist_id'
})Response
Status: 200 OK [
{
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d/57a7f021a713b1c5a6a199b54cc514735d2d462f",
"version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"change_status": {
"deletions": 0,
"additions": 180,
"total": 180
},
"committed_at": "2010-04-14T02:15:15Z"
}
]Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundList gist forks
get /gists/{gist_id}/forksParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/forks await octokit.request('GET /gists/{gist_id}/forks', {
gist_id: 'gist_id'
})Response
Status: 200 OK [
{
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"files": {
"hello_world.rb": {
"filename": "hello_world.rb",
"type": "application/x-ruby",
"language": "Ruby",
"raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
"size": 167
}
},
"public": true,
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 1,
"user": null,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
}
]Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundFork a gist
Note: This was previously /gists/:gist_id/fork.
post /gists/{gist_id}/forksParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
Code samples
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/forks await octokit.request('POST /gists/{gist_id}/forks', {
gist_id: 'gist_id'
})Response
Status: 201 Created {
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"files": {
"hello_world.rb": {
"filename": "hello_world.rb",
"type": "application/x-ruby",
"language": "Ruby",
"raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
"size": 167
}
},
"public": true,
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"truncated": false
}Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundValidation failed
Status: 422 Unprocessable EntityCheck if a gist is starred
get /gists/{gist_id}/starParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/star await octokit.request('GET /gists/{gist_id}/star', {
gist_id: 'gist_id'
})Response if gist is starred
Status: 204 No ContentNot modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenNot Found if gist is not starred
Status: 404 Not FoundStar a gist
Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."
put /gists/{gist_id}/starParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
Code samples
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/star await octokit.request('PUT /gists/{gist_id}/star', {
gist_id: 'gist_id'
})Response
Status: 204 No ContentNot modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundUnstar a gist
delete /gists/{gist_id}/starParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
Code samples
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/star await octokit.request('DELETE /gists/{gist_id}/star', {
gist_id: 'gist_id'
})Response
Status: 204 No ContentNot modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundGet a gist revision
get /gists/{gist_id}/{sha}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
sha | string | path |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/SHA await octokit.request('GET /gists/{gist_id}/{sha}', {
gist_id: 'gist_id',
sha: 'sha'
})Response
Status: 200 OK {
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/"
}Forbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundValidation failed
Status: 422 Unprocessable EntityList gists for a user
Lists public gists for the specified user:
get /users/{username}/gistsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
username | string | path | |
since | string | query | Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/gists await octokit.request('GET /users/{username}/gists', {
username: 'username'
})Response
Status: 200 OK [
{
"url": "https://api.github.com/gists/aa5a315d61ae9438b18d",
"forks_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/forks",
"commits_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/commits",
"id": "aa5a315d61ae9438b18d",
"node_id": "MDQ6R2lzdGFhNWEzMTVkNjFhZTk0MzhiMThk",
"git_pull_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"git_push_url": "https://gist.github.com/aa5a315d61ae9438b18d.git",
"html_url": "https://gist.github.com/aa5a315d61ae9438b18d",
"files": {
"hello_world.rb": {
"filename": "hello_world.rb",
"type": "application/x-ruby",
"language": "Ruby",
"raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb",
"size": 167
}
},
"public": true,
"created_at": "2010-04-14T02:15:15Z",
"updated_at": "2011-06-20T11:34:15Z",
"description": "Hello World Examples",
"comments": 0,
"user": null,
"comments_url": "https://api.github.com/gists/aa5a315d61ae9438b18d/comments/",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"truncated": false
}
]Validation failed
Status: 422 Unprocessable EntityComments
Custom media types for Gist comments
These are the supported media types for gist comments.
application/vnd.github.VERSION.raw
application/vnd.github.VERSION.base64
For more information about media types, see "Custom media types."
List gist comments
get /gists/{gist_id}/commentsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/comments await octokit.request('GET /gists/{gist_id}/comments', {
gist_id: 'gist_id'
})Response
Status: 200 OK [
{
"id": 1,
"node_id": "MDExOkdpc3RDb21tZW50MQ==",
"url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
"body": "Just commenting for the sake of commenting",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-18T23:23:56Z",
"updated_at": "2011-04-18T23:23:56Z",
"author_association": "COLLABORATOR"
}
]Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundCreate a gist comment
post /gists/{gist_id}/commentsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
body | string | body | Required. The comment text. |
Code samples
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/comments \
-d '{"body":"body"}' await octokit.request('POST /gists/{gist_id}/comments', {
gist_id: 'gist_id',
body: 'body'
})Response
Status: 201 Created {
"id": 1,
"node_id": "MDExOkdpc3RDb21tZW50MQ==",
"url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
"body": "Just commenting for the sake of commenting",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-18T23:23:56Z",
"updated_at": "2011-04-18T23:23:56Z",
"author_association": "COLLABORATOR"
}Not modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not FoundGet a gist comment
get /gists/{gist_id}/comments/{comment_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
comment_id | integer | path | comment_id parameter |
Code samples
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/comments/42 await octokit.request('GET /gists/{gist_id}/comments/{comment_id}', {
gist_id: 'gist_id',
comment_id: 42
})Response
Status: 200 OK {
"id": 1,
"node_id": "MDExOkdpc3RDb21tZW50MQ==",
"url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
"body": "Just commenting for the sake of commenting",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-18T23:23:56Z",
"updated_at": "2011-04-18T23:23:56Z",
"author_association": "COLLABORATOR"
}Not modified
Status: 304 Not ModifiedForbidden Gist
Status: 403 ForbiddenResource not found
Status: 404 Not FoundUpdate a gist comment
patch /gists/{gist_id}/comments/{comment_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
comment_id | integer | path | comment_id parameter |
body | string | body | Required. The comment text. |
Code samples
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/comments/42 \
-d '{"body":"body"}' await octokit.request('PATCH /gists/{gist_id}/comments/{comment_id}', {
gist_id: 'gist_id',
comment_id: 42,
body: 'body'
})Response
Status: 200 OK {
"id": 1,
"node_id": "MDExOkdpc3RDb21tZW50MQ==",
"url": "https://api.github.com/gists/a6db0bec360bb87e9418/comments/1",
"body": "Just commenting for the sake of commenting",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-18T23:23:56Z",
"updated_at": "2011-04-18T23:23:56Z",
"author_association": "COLLABORATOR"
}Resource not found
Status: 404 Not FoundDelete a gist comment
delete /gists/{gist_id}/comments/{comment_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
gist_id | string | path | gist_id parameter |
comment_id | integer | path | comment_id parameter |
Code samples
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/GIST_ID/comments/42 await octokit.request('DELETE /gists/{gist_id}/comments/{comment_id}', {
gist_id: 'gist_id',
comment_id: 42
})Response
Status: 204 No ContentNot modified
Status: 304 Not ModifiedForbidden
Status: 403 ForbiddenResource not found
Status: 404 Not Found