Package aiogithubapi
Asynchronous Python client for the GitHub API https://github.com/ludeeus/aiogithubapi
Note: When importing from this module, use `from aiogithubapi import` Anything not available directly in aiogithubapi (defined in `__init__.py`) is considered internal use only, and they can be removed without warning.
Example usage of aiogithubapi
"""Example usage of aiogithubapi."""
import asyncio
from aiogithubapi import GitHubAPI, GitHubDeviceAPI
CLIENT_ID = ""
TOKEN = ""
async def with_device_flow():
"""Example usage of aiogithubapi with Device OAuth flow."""
async with GitHubDeviceAPI(client_id=CLIENT_ID) as device_login:
registration = await device_login.register()
print(
f"Open https://github.com/login/device and enter: {registration.data.user_code}"
)
activation = await device_login.activation(device_code=registration.data.device_code)
async with GitHubAPI(token=activation.data.access_token, **{"client_name": "MyClient/1.2.3"}) as github:
repository = await github.async_get_repository("ludeeus/aiogithubapi")
print("Repository name:", repository.data.name)
print("Repository description:", repository.data.description)
async def with_token():
"""Example usage of aiogithubapi with PAT."""
async with GitHubAPI(token=TOKEN, **{"client_name": "MyClient/1.2.3"}) as github:
repository = await github.async_get_repository("ludeeus/aiogithubapi")
print("Repository name:", repository.data.name)
print("Repository description:", repository.data.description)
asyncio.get_event_loop().run_until_complete(with_token())
Usage notes
- When constructing the client, you should pass a
client_name
parameter, or a user agent string. - Each response object has a
etag
attribute, which can be used to make subsequent requests.- If you pass a
etag
parameter, and the API returns a 304 Not Modified, the client will raiseGitHubNotModifiedException
- If you pass a
Expand source code
"""
Asynchronous Python client for the GitHub API https://github.com/ludeeus/aiogithubapi
.. include:: ../documentation.md
"""
from .common.exceptions import (
AIOGitHubAPIAuthenticationException,
AIOGitHubAPIException,
AIOGitHubAPINotModifiedException,
AIOGitHubAPIRatelimitException,
)
from .const import (
DeviceFlowError,
GitHubClientKwarg,
GitHubIssueLockReason,
GitHubRequestKwarg,
HttpStatusCode,
Repository,
)
from .device import GitHubDeviceAPI
from .exceptions import (
GitHubAuthenticationException,
GitHubConnectionException,
GitHubException,
GitHubGraphQLException,
GitHubNotFoundException,
GitHubNotModifiedException,
GitHubPayloadException,
GitHubPermissionException,
GitHubRatelimitException,
)
from .github import GitHub as GitHubAPI
from .legacy.device import AIOGitHubAPIDeviceLogin as GitHubDevice
from .legacy.github import AIOGitHubAPI as GitHub
from .models.base import GitHubBase
from .models.clones import GitHubClonesModel
from .models.commit import GitHubCommitModel
from .models.contents import GitHubContentsModel
from .models.device_login import GitHubLoginDeviceModel
from .models.events import GitHubEventModel
from .models.git_tree import GitHubGitTreeModel
from .models.issue import GitHubIssueModel
from .models.issue_comment import GitHubIssueCommentModel
from .models.label import GitHubLabelModel
from .models.license import GitHubLicenseModel
from .models.login_oauth import GitHubLoginOauthModel
from .models.meta import GitHubMetaModel
from .models.milestone import GitHubMilestoneModel
from .models.organization import GitHubOrganizationMinimalModel, GitHubOrganizationModel
from .models.owner import GitHubOwnerModel
from .models.permissions import GitHubPermissionsModel
from .models.projects import GitHubProjectModel
from .models.pull_request import GitHubPullRequestModel
from .models.rate_limit import (
GitHubRateLimitModel,
GitHubRateLimitResourceModel,
GitHubRateLimitResourcesModel,
)
from .models.reaction import GitHubReactionModel
from .models.release import GitHubReleaseAssetModel, GitHubReleaseModel
from .models.repository import GitHubRepositoryModel
from .models.request_data import GitHubBaseRequestDataModel
from .models.response import GitHubResponseHeadersModel, GitHubResponseModel
from .models.tag import GitHubTagModel
from .models.user import (
GitHubAuthenticatedUserModel,
GitHubBaseUserModel,
GitHubUserModel,
GitHubUserPlanModel,
)
from .models.views import GitHubViewsModel
Sub-modules
aiogithubapi.client
-
This is the class that do the requests against the API.
aiogithubapi.common
-
Common elements.
aiogithubapi.const
-
Constants for aiogithubapi.
aiogithubapi.device
-
Class for OAuth device flow authentication …
aiogithubapi.exceptions
-
Custom exceptions for aiogithubapi.
aiogithubapi.github
-
AIOGitHubAPI: AIOGitHubAPI
aiogithubapi.graphql_examples
-
Example GraphQL queries
aiogithubapi.helpers
-
Helpers for AIOGitHubAPI.
aiogithubapi.legacy
-
Initialise the legacy module, everything here is considered deprecated.
aiogithubapi.models
-
Initialise aiogithubapi models.
aiogithubapi.namespaces
-
Initialise API namespaces.
aiogithubapi.objects
-
Deprecated