Main class: Github

class github.MainClass.Github(login_or_token=None, password=None, jwt=None, app_auth=None, base_url='https://api.github.com', timeout=15, user_agent='PyGithub/Python', per_page=30, verify=True, retry=None, pool_size=None)

This is the main class you instantiate to access the Github API v3. Optional parameters allow different authentication methods.

Parameters:
  • login_or_token – string
  • password – string
  • jwt – string
  • app_auth – github.AppAuthentication
  • base_url – string
  • timeout – integer
  • user_agent – string
  • per_page – int
  • verify – boolean or string
  • retry – int or urllib3.util.retry.Retry object
  • pool_size – int
FIX_REPO_GET_GIT_REF
Type:bool
per_page
Type:int
rate_limiting

First value is requests remaining, second value is request limit.

Type:(int, int)
rate_limiting_resettime

Unix timestamp indicating when rate limiting will reset.

Type:int
get_rate_limit()

Rate limit status for different resources (core/search/graphql).

Calls:GET /rate_limit
Return type:github.RateLimit.RateLimit
oauth_scopes
Type:list of string
get_license(key=NotSet)
Calls:GET /license/{license}
Parameters:key – string
Return type:github.License.License
get_licenses()
Calls:GET /licenses
Return type:github.PaginatedList.PaginatedList of github.License.License
get_events()
Calls:GET /events
Return type:github.PaginatedList.PaginatedList of github.Event.Event
get_user(login=NotSet)
Calls:GET /users/{user} or GET /user
Parameters:login – string
Return type:github.NamedUser.NamedUser or github.AuthenticatedUser.AuthenticatedUser
get_user_by_id(user_id)
Calls:GET /user/{id}
Parameters:user_id – int
Return type:github.NamedUser.NamedUser
get_users(since=NotSet)
Calls:GET /users
Parameters:since – integer
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
get_organization(login)
Calls:GET /orgs/{org}
Parameters:login – string
Return type:github.Organization.Organization
get_organizations(since=NotSet)
Calls:GET /organizations
Parameters:since – integer
Return type:github.PaginatedList.PaginatedList of github.Organization.Organization
get_repo(full_name_or_id, lazy=False)
Calls:GET /repos/{owner}/{repo} or GET /repositories/{id}
Return type:github.Repository.Repository
get_repos(since=NotSet, visibility=NotSet)
Calls:

GET /repositories

Parameters:
  • since – integer
  • visibility – string (‘all’,’public’)
Return type:

github.PaginatedList.PaginatedList of github.Repository.Repository

get_project(id)
Calls:GET /projects/{project_id}
Return type:github.Project.Project
Parameters:id – integer
get_project_column(id)
Calls:GET /projects/columns/{column_id}
Return type:github.ProjectColumn.ProjectColumn
Parameters:id – integer
get_gist(id)
Calls:GET /gists/{id}
Parameters:id – string
Return type:github.Gist.Gist
get_gists(since=NotSet)
Calls:GET /gists/public
Parameters:since – datetime.datetime format YYYY-MM-DDTHH:MM:SSZ
Return type:github.PaginatedList.PaginatedList of github.Gist.Gist
search_repositories(query, sort=NotSet, order=NotSet, **qualifiers)
Calls:

GET /search/repositories

Parameters:
  • query – string
  • sort – string (‘stars’, ‘forks’, ‘updated’)
  • order – string (‘asc’, ‘desc’)
  • qualifiers – keyword dict query qualifiers
Return type:

github.PaginatedList.PaginatedList of github.Repository.Repository

search_users(query, sort=NotSet, order=NotSet, **qualifiers)
Calls:

GET /search/users

Parameters:
  • query – string
  • sort – string (‘followers’, ‘repositories’, ‘joined’)
  • order – string (‘asc’, ‘desc’)
  • qualifiers – keyword dict query qualifiers
Return type:

github.PaginatedList.PaginatedList of github.NamedUser.NamedUser

search_issues(query, sort=NotSet, order=NotSet, **qualifiers)
Calls:

GET /search/issues

Parameters:
  • query – string
  • sort – string (‘comments’, ‘created’, ‘updated’)
  • order – string (‘asc’, ‘desc’)
  • qualifiers – keyword dict query qualifiers
Return type:

github.PaginatedList.PaginatedList of github.Issue.Issue

search_code(query, sort=NotSet, order=NotSet, highlight=False, **qualifiers)
Calls:

GET /search/code

Parameters:
  • query – string
  • sort – string (‘indexed’)
  • order – string (‘asc’, ‘desc’)
  • highlight – boolean (True, False)
  • qualifiers – keyword dict query qualifiers
Return type:

github.PaginatedList.PaginatedList of github.ContentFile.ContentFile

search_commits(query, sort=NotSet, order=NotSet, **qualifiers)
Calls:

GET /search/commits

Parameters:
  • query – string
  • sort – string (‘author-date’, ‘committer-date’)
  • order – string (‘asc’, ‘desc’)
  • qualifiers – keyword dict query qualifiers
Return type:

github.PaginatedList.PaginatedList of github.Commit.Commit

search_topics(query, **qualifiers)
Calls:

GET /search/topics

Parameters:
  • query – string
  • qualifiers – keyword dict query qualifiers
Return type:

github.PaginatedList.PaginatedList of github.Topic.Topic

render_markdown(text, context=NotSet)
Calls:

POST /markdown

Parameters:
Return type:

string

get_hook(name)
Calls:GET /hooks/{name}
Parameters:name – string
Return type:github.HookDescription.HookDescription
get_hooks()
Calls:GET /hooks
Return type:list of github.HookDescription.HookDescription
get_gitignore_templates()
Calls:GET /gitignore/templates
Return type:list of string
get_gitignore_template(name)
Calls:GET /gitignore/templates/{name}
Return type:github.GitignoreTemplate.GitignoreTemplate
get_emojis()
Calls:GET /emojis
Return type:dictionary of type => url for emoji`
create_from_raw_data(klass, raw_data, headers={})

Creates an object from raw_data previously obtained by github.GithubObject.GithubObject.raw_data, and optionally headers previously obtained by github.GithubObject.GithubObject.raw_headers.

Parameters:
  • klass – the class of the object to create
  • raw_data – dict
  • headers – dict
Return type:

instance of class klass

dump(obj, file, protocol=0)

Dumps (pickles) a PyGithub object to a file-like object. Some effort is made to not pickle sensitive information like the Github credentials used in the Github instance. But NO EFFORT is made to remove sensitive information from the object’s attributes.

Parameters:
  • obj – the object to pickle
  • file – the file-like object to pickle to
  • protocol – the pickling protocol
load(f)

Loads (unpickles) a PyGithub object from a file-like object.

Parameters:f – the file-like object to unpickle from
Returns:the unpickled object
get_app(slug=NotSet)
Calls:GET /apps/{slug} or GET /app
Parameters:slug – string
Return type:github.GithubApp.GithubApp