Use the REST API to list, create, update and delete the public gists on GitHub.
You can use the REST API to view and modify gists. For more information about gists, see Editing and sharing content with gists.
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.
The 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.
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /gists
Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists:
accept (string)application/vnd.github+json is recommended.since (string)
Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
304 - Not modified
403 - Forbidden
Request:
curl -L \
-X GET \
https://api.github.com/gists
Response schema (Status: 200):
Array of Base Gist:
url: required, string, format: uriforks_url: required, string, format: uricommits_url: required, string, format: uriid: required, stringnode_id: required, stringgit_pull_url: required, string, format: urigit_push_url: required, string, format: urihtml_url: required, string, format: urifiles: required, object, additional properties: objectpublic: required, booleancreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timedescription: required, string or nullcomments: required, integercomments_enabled: booleancomments_url: required, string, format: uriowner: Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringtruncated: booleanPOST /gists
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.
accept (string)application/vnd.github+json is recommended.description (string)
Description of the gist
files (object) (required)
Names and content for the files that make up the gist
key (object)content (string) (required)public (boolean or string)
Flag indicating whether the gist is public
201 - Created
304 - Not modified
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/gists \
-d '{
"description": "Example of a gist",
"public": false,
"files": {
"README.md": {
"content": "Hello World"
}
}
}'
Response schema (Status: 201):
fork_of: Gist:
url: required, string, format: uriforks_url: required, string, format: uricommits_url: required, string, format: uriid: required, stringnode_id: required, stringgit_pull_url: required, string, format: urigit_push_url: required, string, format: urihtml_url: required, string, format: urifiles: required, object, additional properties: objectpublic: required, booleancreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timedescription: required, string or nullcomments: required, integercomments_enabled: booleanuser: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringcomments_url: required, string, format: uriowner: any of:
truncated: booleanforks: array of objecthistory: array of objecturl: stringforks_url: stringcommits_url: stringid: stringnode_id: stringgit_pull_url: stringgit_push_url: stringhtml_url: stringfiles: object, additional properties: object or nullpublic: booleancreated_at: stringupdated_at: stringdescription: string or nullcomments: integercomments_enabled: booleanuser: string or nullcomments_url: stringowner: Simple User (see above)truncated: booleanGET /gists/public
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.
accept (string)application/vnd.github+json is recommended.since (string)
Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
304 - Not modified
403 - Forbidden
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X GET \
https://api.github.com/gists/public
Response schema (Status: 200):
Same response schema as List gists for the authenticated user.
GET /gists/starred
List the authenticated user's starred gists:
accept (string)application/vnd.github+json is recommended.since (string)
Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
304 - Not modified
401 - Requires authentication
403 - Forbidden
Request:
curl -L \
-X GET \
https://api.github.com/gists/starred
Response schema (Status: 200):
Same response schema as List gists for the authenticated user.
GET /gists/{gist_id}
Gets a specified gist.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json: Returns the raw markdown. This is the default if you do not pass any specific media type.
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)200 - OK
304 - Not modified
403 - Forbidden Gist
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/gists/GIST_ID
Response schema (Status: 200):
Same response schema as Create a gist.
PATCH /gists/{gist_id}
Allows you to update a gist's description and to update, delete, or rename gist files. Files
from the previous version of the gist that aren't explicitly changed during an edit
are unchanged.
At least one of description or files is required.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json: Returns the raw markdown. This is the default if you do not pass any specific media type.
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)description (string)
The description of the gist.
files (object)
The gist files to be updated, renamed, or deleted. Each key must match the current filename
(including extension) of the targeted gist file. For example: hello.py.
To delete a file, set the whole file to null. For example: hello.py : null. The file will also be
deleted if the specified object does not contain at least one of content or filename.
key (object)content (string)filename (string or null)200 - OK
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PATCH \
https://api.github.com/gists/GIST_ID \
-d '{
"description": "An updated gist description",
"files": {
"README.md": {
"content": "Hello World from GitHub"
}
}
}'
Response schema (Status: 200):
Same response schema as Create a gist.
Request:
curl -L \
-X PATCH \
https://api.github.com/gists/GIST_ID \
-d '{
"files": {
"hello.py": null
}
}'
Response schema (Status: 200):
Same response schema as Create a gist.
Request:
curl -L \
-X PATCH \
https://api.github.com/gists/GIST_ID \
-d '{
"files": {
"hello.py": {
"filename": "goodbye.py"
}
}
}'
Response schema (Status: 200):
Same response schema as Create a gist.
DELETE /gists/{gist_id}
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)204 - No Content
304 - Not modified
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/gists/GIST_ID
Response schema (Status: 204):
GET /gists/{gist_id}/commits
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)
The unique identifier of the gist.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
304 - Not modified
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/gists/GIST_ID/commits
Response schema (Status: 200):
Array of Gist Commit:
url: required, string, format: uriversion: required, stringuser: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringchange_status: required, object:
total: integeradditions: integerdeletions: integercommitted_at: required, string, format: date-timeGET /gists/{gist_id}/forks
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)
The unique identifier of the gist.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
304 - Not modified
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/gists/GIST_ID/forks
Response schema (Status: 200):
Array of Gist Simple:
fork_of: Gist:
url: required, string, format: uriforks_url: required, string, format: uricommits_url: required, string, format: uriid: required, stringnode_id: required, stringgit_pull_url: required, string, format: urigit_push_url: required, string, format: urihtml_url: required, string, format: urifiles: required, object, additional properties: objectpublic: required, booleancreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timedescription: required, string or nullcomments: required, integercomments_enabled: booleanuser: required, any of:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringcomments_url: required, string, format: uriowner: any of:
truncated: booleanforks: array of objecthistory: array of objecturl: stringforks_url: stringcommits_url: stringid: stringnode_id: stringgit_pull_url: stringgit_push_url: stringhtml_url: stringfiles: object, additional properties: object or nullpublic: booleancreated_at: stringupdated_at: stringdescription: string or nullcomments: integercomments_enabled: booleanuser: string or nullcomments_url: stringowner: Simple User (see above)truncated: booleanPOST /gists/{gist_id}/forks
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)201 - Created
304 - Not modified
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/gists/GIST_ID/forks
Response schema (Status: 201):
url: required, string, format: uriforks_url: required, string, format: uricommits_url: required, string, format: uriid: required, stringnode_id: required, stringgit_pull_url: required, string, format: urigit_push_url: required, string, format: urihtml_url: required, string, format: urifiles: required, object, additional properties: objectpublic: required, booleancreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timedescription: required, string or nullcomments: required, integercomments_enabled: booleancomments_url: required, string, format: uriowner: Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringtruncated: booleanGET /gists/{gist_id}/star
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)204 - Response if gist is starred
304 - Not modified
403 - Forbidden
404 - Not Found if gist is not starred
Request:
curl -L \
-X GET \
https://api.github.com/gists/GIST_ID/star
Response schema (Status: 204):
PUT /gists/{gist_id}/star
Note that you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP method."
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)204 - No Content
304 - Not modified
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X PUT \
https://api.github.com/gists/GIST_ID/star
Response schema (Status: 204):
DELETE /gists/{gist_id}/star
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)204 - No Content
304 - Not modified
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/gists/GIST_ID/star
Response schema (Status: 204):
GET /gists/{gist_id}/{sha}
Gets a specified gist revision.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json: Returns the raw markdown. This is the default if you do not pass any specific media type.
accept (string)application/vnd.github+json is recommended.gist_id (string) (required)
The unique identifier of the gist.
sha (string) (required)
200 - OK
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X GET \
https://api.github.com/gists/GIST_ID/SHA
Response schema (Status: 200):
Same response schema as Create a gist.
GET /users/{username}/gists
Lists public gists for the specified user:
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
since (string)
Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X GET \
https://api.github.com/users/USERNAME/gists
Response schema (Status: 200):
Same response schema as List gists for the authenticated user.