Gists services

Fast sample:

from pygithub3 import Github

auth = dict(login='octocat', password='pass')
gh = Github(**auth)

octocat_gists = gh.gists.list()
the_first_gist = gh.gists.get(1)

the_first_gist_comments = gh.gists.comments.list(1)

Gist

class pygithub3.services.gists.Gist(**config)

Consume Gists API

comments

Comments

create(data)

Create a gist

Parameters:data (dict) – Input. See github gists doc
gist_service.create(dict(description='some gist', public=True,
    files={'xample.py': {'content': 'import code'}}))
delete(id)

Delete a gist

Parameters:id (int) – Gist id

Warning

You must be authenticated

fork(id)

Fork a gist

Parameters:id (int) – Gist id

Warning

You must be authenticated

get(id)

Get a single gist

Parameters:id (int) – Gist id
is_starred(id)

Check if a gist is starred

Parameters:id (int) – Gist id

Warning

You must be authenticated

list(user=None)

Get user’s gists

Parameters:user (str) – Username
Returns:A Result

If you call it without user and you are authenticated, get the authenticated user’s gists. but if you aren’t authenticated get the public gists

gist_service.list('copitux')
gist_service.list()
public()

Get public gists

Returns:A Result

Note

Be careful iterating the result

star(id)

Star a gist

Parameters:id (int) – Gist id

Warning

You must be authenticated

starred()

Get authenticated user’s starred gists

Returns:A Result

Warning

You must be authenticated

unstar(id)

Unstar a gist

Parameters:id (int) – Gist id

Warning

You must be authenticated

update(id, data)

Update a single gist

Parameters:

Warning

You must be authenticated

gist_service.update(dict(description='edited',
    files={'xample.py': {
        'filename': 'new_xample.py',
        'content': 'import new_code'}}))

Comments

class pygithub3.services.gists.Comments(**config)

Consume Comments API

Note

This service support MimeTypes configuration

create(gist_id, message)

Create a comment

Parameters:
  • gist_id (int) – Gist id
  • message (str) – Comment’s message

Warning

You must be authenticated

comment_service.create(1, 'comment')
delete(id)

Delete a comment

Parameters:id (int) – Comment id

Warning

You must be authenticated

get(id)

Get a single comment

Parameters:id (int) – Comment id
list(gist_id)

Get gist’s comments

Parameters:gist_id (int) – Gist id
Returns:A Result
update(id, message)

Update a comment

Parameters:
  • id (int) – Comment id
  • message (str) – Comment’s message

Warning

You must be authenticated