Introduction

PyGithub is a Python library to use the Github API v3. With it, you can manage your Github resources (repositories, user profiles, organizations, etc.) from Python scripts.

Should you have any question, any remark, or if you find a bug, or if there is something you can do with the API but not with PyGithub, please open an issue.

(Very short) tutorial

First create a Github instance:

from github import Github

# Authentication is defined via github.Auth
from github import Auth

# using an access token
auth = Auth.Token("access_token")

# Public Web Github
g = Github(auth=auth)

# Github Enterprise with custom hostname
g = Github(auth=auth, base_url="https://{hostname}/api/v3")

Then play with your Github objects:

for repo in g.get_user().get_repos():
    print(repo.name)
    repo.edit(has_wiki=False)
    # to see all the available attributes and methods
    print(dir(repo))

To close connections after use:

g.close()

Download and install

This package is in the Python Package Index, so pip install PyGithub should be enough. You can also clone it on Github.

Licensing

PyGithub is distributed under the GNU Lesser General Public Licence. See files COPYING and COPYING.LESSER, as requested by GNU.

What next?

You need to use a Github API and wonder which class implements it? Reference of APIs.

You want all the details about PyGithub classes? Reference of Classes.

Projects using PyGithub

(Open an issue if you want to be listed here, I’ll be glad to add your project)

They talk about PyGithub