#100DaysOfCode in Python Transcripts
Chapter: Days 55-57: Structured API clients with uplink
Lecture: Demo: Getting started

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, here we are in our GitHub Repo. In the Uplink directory, we're going to quickly create a virtual environment.
0:07 We're going to want to install some third party packages, namely uplink and all of its dependencies. So, you want to have this here, so you don't mess
0:15 with the global one. Now that that's done, we can just drop this into PyCharm, open it however you like. Alright, it's open, there's no files,
0:26 we're starting from an entirely blank project. So let's do two things, let's go over here and add a program and let's add a requirements.txt.
0:37 So, in order to work with Uplink, it probably won't surprise you to know, you have to install Uplink. So we'll come over here and say uplink.
0:44 Now, we're going to install this, however, let's quickly look at the Uplink documentation. So, you can see it's really targeting
0:51 all the versions of Python, great code coverage, really nice, however, there is this sort of note here:
0:58 warning, until this becomes an official version one, maybe don't depend on the exact stability of the API. Chances are, what we're doing
1:07 is really pretty basic and won't change, but I'll show you how we can hedge for that in a second. So let's go over here. Install our requirements,
1:18 and notice, we got Uplink 0.4.0 and we can actually... This will go away in a second. We can come over here and say this is actually == to this.
1:27 And when we do this, it should still just say: "No, no we're all good, everything's installed." That way, when you get this project,
1:35 you can put this and it won't change. In case that API really is unstable, this will let you work with exactly what we're using for this video.
1:43 Now this little green here is just PyCharm saying this is misspelled. We can just save it, tell it no, leave us alone.
1:49 Okay, so we are ready, actually to write some code. And let's just put a little bit of structure in place.
1:57 What we're going to do it we're going to work with a blog service. So, imagine this is a program that lets us edit our own blog, but not from the web.
2:05 We're going to log into our application here and we can say view our existing post, edit our post, we can create new posts,
2:14 really kind of a toy example but, it has much of the RESTful components that any API would have. So, it accepts POST, PUT, DELETE,
2:22 the various verbs and JSON bodies, and other types of interesting things, authentication and headers, and it'll let you play around
2:29 with many of the capabilities without getting into a really super complicated service. So let's just write the skeleton here
2:36 and then we'll go check out the service. Alright, so I'm going to just copy something in and it's just going to like this.
2:41 So, what we're going to do, is we're going to define basically a couple of operations here. We'll use this one first.
2:46 So we're going to have a main method and it's just going to go around and around as long as you don't enter a blank line,
2:52 it's going to ask you, would you like to write a post? Or, read the existing ones? The service starts out with some already there.
2:58 And then it just says each time through, do they say write, do they say read, if not exit. We're going to fill this out with the implementation
3:07 of talking to the API.


Talk Python's Mastodon Michael Kennedy's Mastodon