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, lazy: bool = False)
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
lazy – completable objects created from this instance are lazy, as well as completable objects created from those, and so on
- withLazy(lazy: bool) Github
Create a Github instance with identical configuration but the given lazy setting.
- Parameters:
lazy – completable objects created from this instance are lazy, as well as completable objects created from those, and so on
- Returns:
new Github instance
- 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: Requester
Return my Requester object.
For example, to make requests to API endpoints not yet supported by PyGitHub.
- property rate_limiting: tuple[int, int]
First value is requests remaining, second value is request limit.
- property rate_limiting_resettime: int
Unix timestamp indicating when rate limiting will reset.
- get_rate_limit() RateLimitOverview
Rate limit overview that provides general status and status for different resources (core/search/graphql).
- Calls:
- property oauth_scopes: list[str] | None
- Type:
list of string
- get_licenses() PaginatedList[License]
- Calls:
- get_events() PaginatedList[Event]
- Calls:
- get_user(login: Opt[str] = NotSet, lazy: Opt[bool] = NotSet) NamedUser | AuthenticatedUser
- Calls:
- get_users(since: Opt[int] = NotSet) PaginatedList[NamedUser]
- Calls:
- get_organization(org: str) Organization
- Calls:
- get_organizations(since: Opt[int] = NotSet) PaginatedList[Organization]
- Calls:
- get_enterprise(enterprise: str) Enterprise
- Calls:
- Parameters:
enterprise – string
- Return type:
Enterprise
- get_repo(full_name_or_id: int | str, lazy: Opt[bool] = NotSet) Repository
- get_repos(since: Opt[int] = NotSet, visibility: Opt[str] = NotSet) PaginatedList[Repository]
- Calls:
- Parameters:
since – integer
visibility – string (‘all’,’public’)
- get_project_column(id: int) ProjectColumn
- 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.PaginatedListofgithub.GlobalAdvisory.GlobalAdvisory
- search_repositories(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) PaginatedList[RepositorySearchResult]
- 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[NamedUserSearchResult]
- Calls:
- Parameters:
query – string
sort – string (‘followers’, ‘repositories’, ‘joined’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
- Return type:
PaginatedListofgithub.NamedUser.NamedUserSearchResult
- search_issues(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) PaginatedList[IssueSearchResult]
- Calls:
- Parameters:
query – string
sort – string (‘comments’, ‘created’, ‘updated’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
- Return type:
PaginatedListofgithub.Issue.IssueSearchResult
- search_code(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, highlight: bool = False, **qualifiers: Any) PaginatedList[ContentFileSearchResult]
- Calls:
- Parameters:
query – string
sort – string (‘indexed’)
order – string (‘asc’, ‘desc’)
highlight – boolean (True, False)
qualifiers – keyword dict query qualifiers
- Return type:
PaginatedListofgithub.ContentFile.ContentFileSearchResult
- search_commits(query: str, sort: Opt[str] = NotSet, order: Opt[str] = NotSet, **qualifiers: Any) PaginatedList[CommitSearchResult]
- Calls:
- Parameters:
query – string
sort – string (‘author-date’, ‘committer-date’)
order – string (‘asc’, ‘desc’)
qualifiers – keyword dict query qualifiers
- Return type:
PaginatedListofgithub.Commit.CommitSearchResult
- search_topics(query: str, **qualifiers: Any) PaginatedList[Topic]
- Calls:
- Parameters:
query – string
qualifiers – keyword dict query qualifiers
- Return type:
PaginatedListofgithub.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) HookDescription
- Calls:
- get_hooks() list[HookDescription]
- Calls:
- Return type:
- get_hook_delivery(hook_id: int, delivery_id: int) 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: 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
Githubinstance. 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: 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