API Reference¶
Client¶
- class github.GHClient(*, username=None, token=None, user_cache_size=30, repo_cache_size=15, custom_headers={})¶
The main client, used to start most use-cases.
- Parameters
username (Optional[
str
]) – An optional username to be provided along with a token to make authenticated API calls. If you provide a username, the token must be provided as well.user_cache_size (Optional[
int
]) – Determines the maximum number of User objects that will be cached in memory. Defaults to 30, must be between 30 and 0 inclusive.repo_cache_size (Optional[
int
]) – Determines the maximum number of Repository objects that will be cached in memory. Defaults to 15, must be between 30 and 0 inclusive.custom_headers (Optional[
dict
]) – A way to pass custom headers into the client session that drives the client, eg. a user-agent.
- check_limits(as_dict=False)¶
Returns the remaining number of API calls per timeframe.
- Parameters
as_dict (Optional[
bool
]) – Set to True to return the remaining calls in a dictionary. Set to False to return the remaining calls in a list. Defaults to False
- await update_auth(*, username, token)¶
Allows you to input auth information after instantiating the client.
- await start()¶
Main entry point to the wrapper, this creates the ClientSession.
- await get_user(*, user)¶
User
: Fetch a Github user from their username.- Parameters
user (
str
) – The name of the user to fetch.
- await get_repo(*, owner, repo)¶
Repository
: Fetch a Github repository from it’s name.
- await create_repo(name, description='Repository created using Github-Api-Wrapper.', public=False, gitignore=None, license=None)¶
Creates a Repository with supplied data. Requires API authentication.
- Parameters
name (
str
) – The name of the repository to be created.description (
str
) – A description of the repository to be created.public (
bool
) – Determines whether only the repository will be visible to the public. Defaults to False (private repository).gitignore (Optional[
str
]) – .gitignore template to use. See https://github.com/github/gitignore for GitHub’s own templates. Defaults to None.license (Optional[
str
]) – TODO: Document this.
- Return type
- await delete_repo(repo)¶
Delete a Github repository, requires authorisation.
- await get_gist(gist)¶
Fetch a Github gist from it’s id.
- await create_gist(*, files, description='Gist from Github-Api-Wrapper', public=True)¶
Creates a Gist with the given files, requires authorisation.
- await delete_gist(gist)¶
Delete a Github gist, requires authorisation.
- await get_org(org)¶
Fetch a Github organization from it’s name.
- Parameters
org (
str
) – The name of the organization to fetch.- Return type
- await close()¶
Close the session.
API Models¶
APIObject¶
- class github.APIObject¶
Top level class for objects created from the API
User¶
PartialUser¶
- class github.PartialUser¶
Repository¶
Issue¶
- class github.Issue¶
Representation of an issue on Github.
- created_at¶
The time the issue was created.
- Type
- closed_by¶
The user the issue was closed by, if applicable.
- Type
Optional[Union[
PartialUser
,User
]]
- property updated_at¶
The time the issue was last updated, if applicable.
- Type
Optional[
datetime.datetime
]
File¶
- class github.File¶
A wrapper around files and in-memory file-like objects.
- Parameters
fp (Union[
str
,io.StringIO
,io.BytesIO
]) – The filepath or StringIO representing a file to upload. If providing a StringIO instance, a filename shuold also be provided to the file.filename (
str
) – An override to the file’s name, encouraged to provide this if using a StringIO instance.
Gist¶
- class github.Gist¶
Representation of a gist on Github.
- owner¶
The owner of the gist.
- Type
Union[
PartialUser
,User
]
- created_at¶
The time the gist was created at.
- Type
- property updated_at¶
The time the gist was last updated, if applicable.
- Type
Optional[
datetime.datetime
]
- property comments¶
document this.
- Type
TODO
- property discussion¶
document this.
- Type
TODO
- property raw¶
document this.
- Type
TODO
- await delete()¶
Delete the gist.