Github class is a glue to all of them and the recommended option to start


You can access to the API requests through the different services.

If you take a look at github API v3 documentation, you’ll see a few sections in the sidebar.

pygithub3 has one service per each section of request-related

For example:

repos => services.repos.repo
    collaborators => services.repos.collaborators
    commits => services.repos.commits

Each service has the functions to throw the API requests and is isolated from the rest.

Config each service

Each service can be configurated with some variables (behind the scenes, each service has her client which is configurated with this variables).


Also you can configure Github as a service


You can configure each service with this keyword variables:

  • login (str) – Username to authenticate
  • password (str) – Username to authenticate
  • user (str) – Default username in requests
  • repo (str) – Default repository in requests
  • token (str) – Token to OAuth
  • per_page (int) – Items in each page of multiple returns
  • base_url (str) – To support another github-related API (untested)
  • verbose (stream) – Stream to write debug logs

You can configure the authentication with BasicAuthentication (login and password) and with OAuth ( token). If you include login, password and token in config; Oauth has precedence

Some API requests need user and/or repo arguments (e.g repos service). You can configure the default value here to avoid repeating

Some API requests return multiple resources with pagination. You can configure how many items has each page.

You can configure verbose logging like requests library

set_credentials(login, password)

Set Basic Authentication

  • login (str) – Username to authenticate
  • password (str) – Username to authenticate

Set repository

Parameters:repo (str) – Default repository in requests

Set OAuth token

Parameters:token (str) – Token to OAuth

Set user

Parameters:user (str) – Default username in requests


Some services supports mimetypes

With them the Resources will have body, body_text, body_html attributes or all of them.


Mimetype support to Services

Adds 4 public functions to service:


Resource will have body, body_text and body_html attributes


Resource will have body_html attribute


Resource will have body attribute


Resource will have body_text attribute

Fast example:

from pygithub3 import Github

gh = Github()

comment = gh.gists.comments.list(1).all()[0]
print comment.body, comment.body_text, comment.body_html