Quick Start#
Welcome to quick start section. We will explain here how to get started using the PyOctocat library. Great efforts have been made to make the API as high-level, readable and intuitive as possible. Overall, we are happy with the results and hope that the behavior of this library will also appeal to users.
Creating a GitHub client#
As library name implies, PyOctocat is mainly designed to be asynchronous
library and thus requires code to be run in async
functions.
Therefore basic template which will be used for rest of this tutorial looks
following way:
All executable code goes into async def main()
function shown above.
Imports can be still kept at the top of the file (and it is recommended).
To begin with using PyOctocat, you will have to create instance of GitHub object, which takes username and github token as arguments. It will be used to acquire objects from Github API and control session availability.
Interacting with Github API#
Important
ALL interaction with Github API (sending and receiving data) can only be
done withing async with
block in async
function.
All interaction, requiring internet access, outside async with
,
will either fail or finish with unexpected results.
At this point we can acquire user information via Github API with call to
.user(...)
function. When called with no arguments, it will return currently
authenticated user, otherwise expects string containing user name and returns
wrapper object containing details acquired from API.
Having the user object, we can get the repository of which he is the owner. We do this by using the repository() method, which takes the name of the repository as an argument.
Info
Your next steps depend on your needs, unfortunately rest of API is currently not implemented. Hopefully, in the next release we will put in your hands the tools to use the data contained in the repository.
Created: July 3, 2022