Gist API Objects

The Gists API has a rich set of objects it returns.

Gist Representations

classgithub3.gists.gist.ShortGist(json,session:GitHubSession)

Short representation of a gist.

GitHub’s API returns different amounts of information about gistsbased upon how that information is retrieved. This object exists torepresent the full amount of information returned for a specificgist. For example, you would receive this class when callingall_gists(). To provide a clear distinctionbetween the types of gists, github3.py uses different classes withdifferent sets of attributes.

This object only has the following attributes:

url

The GitHub API URL for this repository, e.g.,https://api.github.com/gists/6faaaeb956dec3f51a9bd630a3490291.

comments_count

Number of comments on this gist

description

Description of the gist as written by the creator

html_url

The URL of this gist on GitHub, e.g.,https://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291

id

The unique identifier for this gist.

public

This is a boolean attribute describing if the gist is public orprivate

git_pull_url

The git URL to pull this gist, e.g.,git://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git

git_push_url

The git URL to push to gist, e.g.,git@gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git

created_at

This is a datetime object representing when the gist was created.

updated_at
Thisisadatetimeobjectrepresentingthelasttimethisgistwas
mostrecentlyupdated.
owner

This attribute is aShortUser objectrepresenting the creator of the gist.

files

A dictionary mapping the filename to aGistFile object.

Changed in version 1.0.0:Previously this was a list but it has been converted to adictionary to preserve the structure of the API.

comments_url

The URL to retrieve the list of comments on the Gist via the API.

classgithub3.gists.gist.GistFork(json,session:GitHubSession)

This object represents a forked Gist.

This has a subset of attributes of aShortGist:

created_at

The date and time when the gist was created.

id

The unique identifier of the gist.

owner

The user who forked the gist.

updated_at

The date and time of the most recent modification of the fork.

url

The API URL for the fork.

classgithub3.gists.gist.Gist(json,session:GitHubSession)

This object constitutes the full representation of a Gist.

GitHub’s API returns different amounts of information about gistsbased upon how that information is retrieved. This object exists torepresent the full amount of information returned for a specificgist. For example, you would receive this class when callinggist(). To provide a clear distinctionbetween the types of gists, github3.py uses different classes withdifferent sets of attributes.

This object has all the same attributes asShortGist as well as:

commits_url

The URL to retrieve gist commits from the GitHub API.

original_forks

A list ofGistFork objects representingeach fork of this gist. To retrieve the most recent list of forks, usetheforks() method.

forks_url

The URL to retrieve the current listing of forks of this gist.

history

A list ofGistHistory objectsrepresenting each change made to this gist.

truncated

This is a boolean attribute that indicates whether the content of thisGist has been truncated or not.

Files in a Gist

Gists have files which have two representations:

classgithub3.gists.file.GistFile(json,session:GitHubSession)

This represents the full file object returned by interacting with gists.

The object has all of the attributes as returned by the API for aShortGistFile as well as:

truncated

A boolean attribute that indicates whetheroriginal_contentcontains all of the file’s contents.

original_content

The contents of the file (potentially truncated) returned by the API.If the file was truncated usecontent() to retrieve it in itsentirety.

classgithub3.gists.file.ShortGistFile(json,session:GitHubSession)

This represents the file object returned by interacting with gists.

The object has the following attributes as returned by the API for a Gist:

raw_url

This URL provides access to the complete, untruncated content of thefile represented by this object.

filename

The string for the filename.

language

The GitHub detected language for the file, e.g., Erlang, Python, text.

type

The mime-type of the file. Related tolanguage.

size

The file size in bytes.

The History of a Gist

classgithub3.gists.history.GistHistory(json,session:GitHubSession)

This object represents one version (or revision) of a gist.

The GitHub API returns the following attributes:

url

The URL to the revision of the gist retrievable through the API.

version

The commit ID of the revision of the gist.

user

TheShortUser representation of the user whoowns this gist.

committed_at

The date and time of the revision’s commit.

change_status

A dictionary with the number of deletions, additions, and totalchanges to the gist.

For convenience, github3.py also exposes the following attributes from thechange_status:

additions

The number of additions to the gist compared to the previous revision.

deletions

The number of deletions from the gist compared to the previousrevision.

total

The total number of changes to the gist compared to the previousrevision.