Consuming HTTP Services in Python Transcripts
Chapter: Consuming RESTful HTTP services
Lecture: Exploring the Basecamp HTTP API

Login or purchase this course to watch this video and the rest of the course contents.
0:02 Let's look at a real API, this API is going to be the latest new API,
0:08 you can see modified just 25 days ago, and and created eight months ago,
0:12 so it's quite new for Basecamp.
0:15 So, Basecamp is a project management site that is pretty well known in the tech,
0:19 especially the web industry for a couple of reasons,
0:22 so it was created by this company called "37 Signals"
0:25 and they were a web design company,
0:28 and it turned out their product Basecamp was way more popular
0:30 and profitable and interesting than actually just being a web consulting company,
0:35 so they basically started selling Basecamp as their main thing,
0:39 they just built it for themselves internally,
0:42 and it's also notable because this is where Ruby on Rails comes from,
0:47 DHH and Jason Fried and the guys at 37 built Basecamp
0:52 and they said oh we have this really cool unique way of writing web apps
0:55 let's extract that as a framework and we'll call that Ruby on Rails, so that's all good.
0:58 There is no more "37 Signals" anymore
1:00 because they just renamed their company name to Basecamp,
1:04 after a while which is pretty interesting, but let's look at their API,
1:07 this is pretty new, we'll go over here and actually pull up some details
1:11 that I have already gotten us too, so we can go check out what are called Basecamps,
1:14 you can see, recently updated by DHH and we can do things like a get request,
1:19 so there is an API url and they are just going to use the short relative url,
1:25 so if we want to get all the Basecmaps, we can just do get/projects
1:29 and they have everything returning json and make it super explicit they say .json, okay.
1:34 So what else can we do, so if we want to read data about the projects we do a get,
1:39 if we want to read specific, here is the list of projects that come back,
1:42 if we want to get a particular one, let's say one with id 1,
1:46 we issue a get request against projects/1/json, okay,
1:50 and then, we get information back here like so, right,
1:55 so when it was created, its name, its description and so on, and so on,
1:59 so lots of information about that project.
2:02 On the other hand, if we want to create a project, or a Basecamp,
2:05 just like I said, we are going to use a post to create something,
2:08 we don't know what its id is going to be, it's going to be generated by the server,
2:11 but we know we want to make one so we are going to do a post against projects.json
2:15 and this is the data that we are going to send,
2:18 just the required data, the name, the description,
2:21 and then of course, this stuff that is up here will all be generated by the server,
2:23 and presumably returned to us.
2:26 We also might get a hey, error, you are not allowed to create one of these,
2:29 you are out of space or whatever, the other notable thing to look at is
2:32 look at the use of the status codes, instead of just always returning 200
2:37 and maybe returning 200 response code, with an error that says sorry,
2:42 they are actually returning status codes that mean specific things,
2:47 so a 201 specifically means created so you should look for that in this example.
2:52 A 507 specifically means insufficient storage,
2:55 and they are using that to represent the status code meaning of this error
2:59 and they give you text, just so you also know.
3:01 Let's see, there is a few other things we can check out here,
3:05 if we want to update, no surprise, we are going to do a put against that thing
3:08 and this will replace the name and replace the description supposedly,
3:11 this is going to come back with a 200 and say yeah that worked, and again,
3:14 we are going to do a delete, so we are going to come up here
3:17 and if we want to do a delete to this thing, and the status code is 204,
3:20 no content which is typically the agreed upon status code for delete.
3:24 So, this is just the project management side of Basecamp
3:28 or the API for managing projects and Basecamp which they call Basecamps,
3:33 but there is lots of other pieces, you can scroll down and see what we have here,
3:36 they have Basecamps, the have comments, documents
3:40 but the whole API is very restful and it makes strong use of urls that point at nouns
3:46 and leveraging the http verbs against those nouns to have meaning.
3:52 Alright, so in the next section we are going to work with the surface
3:56 that I've created that lets us do all sorts of modifications,
3:59 create stuff, update stuff, delete stuff and so on,
4:02 and we are going to see how to take this idea and use it on the client side.