From the course: Data Ingestion with Python
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: GitHub API - Python Tutorial
From the course: Data Ingestion with Python
Solution: GitHub API
(upbeat music) - [Instructor] If you look at the documentation you see that we need to do a GET request to slash users and the username. The internal object is a JSON object that has created at which is the time the user joined GitHub. Let's look at the code. So we define user time with the URL which is api.github.com/users/ and then login. We use urlopen from the standard library to get a response and json to post the JSON response. The created at is a string and we need to convert it to a datetime object. So we do that by trimming the final Z and using fromisoformat. And lastly at line 14 we create datetime/utcnow - created. As an example in line 17 and 18, we can check out how much time I am a member of GitHub. Let's run it. Python, github.py. I'm a member for almost 3800 days.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.