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