Main class: Github¶
-
class
github.MainClass.
Github
(login_or_token: str | None = None, password: str | None = None, jwt: str | None = None, app_auth: AppAuthentication | None = None, base_url: str = 'https://api.github.com', timeout: int = 15, user_agent: str = 'PyGithub/Python', per_page: int = 30, verify: bool | str = True, retry: int | Retry | None = GithubRetry(total=10, connect=None, read=None, redirect=None, status=None), pool_size: int | None = None, seconds_between_requests: float | None = 0.25, seconds_between_writes: float | None = 1.0, auth: github.Auth.Auth | None = 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 deprecated, use auth=github.Auth.Login(…) or auth=github.Auth.Token(…) instead
password – string deprecated, use auth=github.Auth.Login(…) instead
jwt – string deprecated, use auth=github.Auth.AppAuth(…) or auth=github.Auth.AppAuthToken(…) instead
app_auth – github.AppAuthentication deprecated, use auth=github.Auth.AppInstallationAuth(…) instead
base_url – string
timeout – integer
user_agent – string
per_page – int
verify – boolean or string
retry – int or urllib3.util.retry.Retry object, defaults to github.Github.default_retry, set to None to disable retries
pool_size – int
seconds_between_requests – float
seconds_between_writes – float
auth – authentication method
-
close
() → None¶ Close connections to the server. Alternatively, use the Github object as a context manager:
with github.Github(...) as gh: # do something
-
property
requester
¶ Return my Requester object.
For example, to make requests to API endpoints not yet supported by PyGitHub.
-
property
rate_limiting
¶ First value is requests remaining, second value is request limit.
-
property
rate_limiting_resettime
¶ Unix timestamp indicating when rate limiting will reset.
-
get_rate_limit
() → github.RateLimit.RateLimit¶ Rate limit status for different resources (core/search/graphql).
- Calls
`GET /rate_limit
-
property
oauth_scopes
¶ - Type
list of string
-
get_license
(key: Opt[str] = NotSet) → License¶ - Calls
-
get_licenses
() → PaginatedList[License]¶ - Calls
-
get_events
() → PaginatedList[Event]¶ - Calls
-
get_user
(login: Opt[str] = NotSet) → NamedUser | AuthenticatedUser¶ - Calls
-
get_user_by_id
(user_id: int) → NamedUser¶ - Calls
- Parameters
user_id – int
- Return type
-
get_users
(since: Opt[int] = NotSet) → PaginatedList[NamedUser]¶ - Calls
-
get_organization
(login: str) → Organization¶ - Calls
-
get_organizations
(since: Opt[int] = NotSet) → PaginatedList[Organization]¶ - Calls
-
get_enterprise
(enterprise: str) → github.Enterprise.Enterprise¶ - Calls
- Parameters
enterprise – string
- Return type
Enterprise
-
get_repo
(full_name_or_id: int | str, lazy: bool = False) → Repository¶
-
get_repos
(since: Opt[int] = NotSet, visibility: Opt[str] = NotSet) → PaginatedList[Repository]¶ - Calls
- Parameters
since – integer
visibility – string (‘all’,’public’)
-
get_project
(id: int) → Project¶
-
get_project_column
(id: int) → ProjectColumn¶
-
get_gist
(id: str) → Gist¶ - Calls
-
get_gists
(since: Opt[datetime] = NotSet) → PaginatedList[Gist]¶ - Calls
-
get_global_advisory
(ghsa_id: str) → GlobalAdvisory¶ - Calls
- Parameters
ghsa_id – string
- Return type
-
get_global_advisories
(type: Opt[str] = NotSet, ghsa_id: Opt[str] = NotSet, cve_id: Opt[str] = NotSet, ecosystem: Opt[str] = NotSet, severity: Opt[str] = NotSet, cwes: list[Opt[str]] | Opt[str] = NotSet, is_withdrawn: Opt[bool] = NotSet, affects: list[str] | Opt[str] = NotSet, published: Opt[str] = NotSet, updated: Opt[str] = NotSet, modified: Opt[str] = NotSet, keywords: Opt[str] = NotSet, before: Opt[str] = NotSet, after: Opt[str] = NotSet, per_page: Opt[str] = NotSet, sort: Opt[str] = NotSet, direction: Opt[str] = NotSet) → PaginatedList[GlobalAdvisory]¶ - Calls
GET /advisories <https://docs.github.com/en/rest/security-advisories/global-advisories>
- Parameters
type – Optional string
ghsa_id – Optional string
cve_id – Optional string
ecosystem – Optional string
severity – Optional string
cwes – Optional comma separated string or list of integer or string
is_withdrawn – Optional bool
affects – Optional comma separated string or list of string
published – Optional string
updated – Optional string
modified – Optional string
before – Optional string
after – Optional string
sort – Optional string
direction – Optional string
- Return type
github.PaginatedList.PaginatedList
ofgithub.GlobalAdvisory.GlobalAdvisory
-
search_repositories
(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) → PaginatedList[Repository]¶ - Calls
- Parameters
query – string
sort – string (‘stars’, ‘forks’, ‘updated’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
-
search_users
(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) → PaginatedList[NamedUser]¶ - Calls
- Parameters
query – string
sort – string (‘followers’, ‘repositories’, ‘joined’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
- Return type
PaginatedList
ofgithub.NamedUser.NamedUser
-
search_issues
(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) → PaginatedList[Issue]¶ - Calls
- Parameters
query – string
sort – string (‘comments’, ‘created’, ‘updated’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
- Return type
PaginatedList
ofgithub.Issue.Issue
-
search_code
(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, highlight: bool = False, **qualifiers: Any) → PaginatedList[ContentFile]¶ - Calls
- Parameters
query – string
sort – string (‘indexed’)
order – string (‘asc’, ‘desc’)
highlight – boolean (True, False)
qualifiers – keyword dict query qualifiers
- Return type
PaginatedList
ofgithub.ContentFile.ContentFile
-
search_commits
(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) → PaginatedList[Commit]¶ - Calls
- Parameters
query – string
sort – string (‘author-date’, ‘committer-date’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
- Return type
PaginatedList
ofgithub.Commit.Commit
-
search_topics
(query: str, **qualifiers: Any) → PaginatedList[Topic]¶ - Calls
- Parameters
query – string
qualifiers – keyword dict query qualifiers
- Return type
PaginatedList
ofgithub.Topic.Topic
-
render_markdown
(text: str, context: Opt[Repository] = NotSet) → str¶ - Calls
- Parameters
text – string
context –
github.Repository.Repository
- Return type
string
-
get_hook
(name: str) → github.HookDescription.HookDescription¶ - Calls
-
get_hooks
() → list[HookDescription]¶ - Calls
- Return type
-
get_hook_delivery
(hook_id: int, delivery_id: int) → github.HookDelivery.HookDelivery¶ - Calls
- Parameters
hook_id – integer
delivery_id – integer
- Return type
HookDelivery
-
get_hook_deliveries
(hook_id: int) → list[HookDeliverySummary]¶ - Calls
- Parameters
hook_id – integer
- Return type
list of
HookDeliverySummary
-
get_gitignore_templates
() → list[str]¶ - Calls
-
get_gitignore_template
(name: str) → GitignoreTemplate¶
-
get_emojis
() → dict[str, str]¶ - Calls
- Return type
dictionary of type => url for emoji`
-
create_from_raw_data
(klass: type[TGithubObject], raw_data: dict[str, Any], headers: dict[str, str | int] | None = None) → TGithubObject¶ Creates an object from raw_data previously obtained by
GithubObject.raw_data
, and optionally headers previously obtained byGithubObject.raw_headers
.- Parameters
klass – the class of the object to create
raw_data – dict
headers – dict
- Return type
instance of class
klass
-
dump
(obj: github.GithubObject.GithubObject, file: BinaryIO, protocol: int = 0) → None¶ 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 :param file: the file-like object to pickle to :param protocol: the
- pickling protocol
- param obj
the object to pickle :param file: the file-like object to pickle to :param protocol: the
- `pickling protocol <https://python.readthedocs.io/en/latest/library/pickle.html#data-
- param obj
the object to pickle :param file: the file-like object to pickle to :param protocol: the
- `pickling protocol <https://python.readthedocs.io/en/latest/library/pickle.html#data-
stream-format>`_ :param obj: the object to pickle :param file: the file-like object to pickle to :param
protocol: the `pickling protocol <https://python.readthedocs.io/en/latest/library/pickle.html#data- :param obj: the object to pickle :param file: the file-like object to pickle to :param protocol: the `pickling protocol <https://python.readthedocs.io/en/latest/library/pickle.html#data-
stream-format>`_
- Parameters
obj – the object to pickle
file – the file-like object to pickle to
protocol – the `pickling protocol <https://python.readthedocs.io/en/latest/library/pickle.html#data-
obj – the object to pickle
file – the file-like object to pickle to
protocol –
obj – the object to pickle
file – the file-like object to pickle to
protocol –
-
load
(f: BinaryIO) → Any¶ 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: Opt[str] = NotSet) → GithubApp¶ - Calls