Consuming HTTP Services in Python Transcripts
Chapter: Consuming RESTful HTTP services
Lecture: HTTP and REST building blocks

Login or purchase this course to watch this video and the rest of the course contents.
0:02 Let's take a moment and discuss the http and restful building blocks.
0:06 So where are we in our course, we are back sort of focused generally on the http clients,
0:10 so what are the building blocks that make up these http services
0:14 and to even larger degree restful services?
0:17 You'll see that restful services technically are like a specialization of http services,
0:22 they are basically http services with a certain number of criteria not all http services,
0:28 maybe most don't actually support every restful principle let's say.
0:33 So what are the building block? Well, obviously, the http or https protocol,
0:37 these are things that transfer over the internet,
0:41 over the same protocol that web browsers use.
0:44 And they focus on resources, so the way that you describe stuff in your API
0:49 often is some kind of noun, or set of nouns
0:53 and we have resources or urls that point at these resources,
0:57 so imagine we're basecamp, we might have users /api/users,
1:02 we might have projects /api/projects,
1:06 maybe a particular project so /api/project/7 or whatever,
1:11 and then unlike the traditional remote method in vocation type or services
1:15 that are made up of verbs and actions, so things like get users, log in, and so on,
1:20 we'll see that these http services are built upon nouns.
1:24 And the way that we perform actions on them is with the http verbs,
1:28 so we might do a get again, /users/one,
1:31 that means give me the details about user number one.
1:34 Maybe we want to create a new user, so we do a post against /users, things like that,
1:38 so it's the http verbs plus the nouns that are the resources,
1:41 that together make up our http services.
1:44 Now, most services you run into, kind of stop there,
1:47 if you are talking about restful services there is a couple more levels
1:50 we got to go into so you might have resource discovery,
1:54 so APIs like basecamp and other sort of well known APIs github and so on,
1:59 they list exactly what their resources are, but certain types of restful services don't,
2:04 the just say start here and we'll give you a bunch of urls
2:08 and then you can explore further, using those urls, so that is resource discovery.
2:13 The other thing that we could do but many services don't,
2:17 is content negotiation, at a super low level,
2:19 maybe you've got a /users/one and you have the ability to either access that
2:25 and get the result back as json or as xml,
2:28 so if you set the accept type header either in your client or your browser,
2:33 you are going to get whatever you put there,
2:36 so json gives you json, xml gives you xml, you could even go so far to say
2:40 I accept an image and it will give you the profile image back.
2:42 But, most services really say you do this request, "you get some json,
2:47 you do that request, you get some xml", it's a little less dynamic
2:50 but if you talk full restful services, this is typically part of what is included.