Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

REST API endpoints for gists

Use the REST API to list, create, update and delete the public gists on GitHub.

About gists

You can use the REST API to view and modify gists. For more information about gists, see Editing and sharing content with gists.

Authentication

You can read public gists and create them for anonymous users without a token. 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 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.

List gists for the authenticated user

Lists the authenticated user's gists or if called anonymously, this endpoint returns all public gists:

Fine-grained access tokens for "List gists for the authenticated user"

This endpoint works with the following fine-grained token types:

The fine-grained token does not require any permissions.

Parameters for "List gists for the authenticated user"

Headers
Name, Type, Description
accept string

Setting to application/vnd.github+json is recommended.

Query parameters
Name, Type, Description
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

HTTP response status codes for "List gists for the authenticated user"

Status codeDescription
200

OK

304

Not modified

403

Forbidden

Code samples for "List gists for the authenticated user"

Request example

get/gists
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/gists

Response