#100DaysOfCode in Python Transcripts
Chapter: Days 61-63: Using the Github API with Python
Lecture: Setup and creating a Github user object

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, let's get started. First, we need to pip install pygithub, which is the module we are going to use to query the API and post to it.
0:13 So, let's head over to my terminal, and create a virtual environment. Let's create a directory, CD into it,
0:23 and, as explained in other videos, I have an alias to create virtual environments based on my use of Anaconda. So I found a virtual env with the path
0:35 pointing to my Python binary in Anaconda, that's the best way for me to do it, but as you've probably seen in other videos,
0:43 another way to do it is Python -m venv, and the name of your venv, which I usually call venv by convention. That's totally cool as well.
0:55 But I'm going to go with my setup. Then you have to enable the virtual environment. So, I'm doing that often because I use virtual environments
1:06 for every project I work on, I have an alias. So, I can just type ae, and I'm in. So as you see we are starting from a clean slate,
1:17 and I'm going to do pip install pygithub. So with that done, head over to the notebook,
1:34 and note that I have the virtual environment enabled. Here's how you can do that. You need to pip install ipykernel,
1:46 and then there's a command that you can set your virtual environment inside the notebook. That's why you see me using venv here,
1:56 and having access to pygithub. So, let's import the modules we are going to use. And it's a bit inconsistent,
2:05 so the package is called pyGitHub, camel-cased, but you actually use it as github lowercased. Now, let's make a Github object.
2:24 And now I can work with that object. Notice that we didn't log in, so we're a bit limited in the amount of calls we can make to the API at this point.
2:39 And you will see later that when we make this object with a token, we can make many more calls to the API. And let's work with our PyBites user.
2:52 So, I'm going to store the user in pb. And there you go, and before retrieving data from the API, let's take a little bit of a detour
3:09 to show you the help functions in Python. And that's because I've found the documentation not very complete and helpful for this module,
3:17 so, when I worked with this module for a co-challenged platform, I used help and there to inspect the module and see what was available for use.
3:27 So that's why I want to give you those tips as well.


Talk Python's Mastodon Michael Kennedy's Mastodon