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:07 So where are we in our course, we are back sort of focused generally on the http clients,
0:11 so what are the building blocks that make up these http services and to even larger degree restful services?
0:18 You'll see that restful services technically are like a specialization of http services,
0:23 they are basically http services with a certain number of criteria not all http services,
0:29 maybe most don't actually support every restful principle let's say. So what are the building block? Well, obviously, the http or https protocol,
0:38 these are things that transfer over the internet, over the same protocol that web browsers use.
0:45 And they focus on resources, so the way that you describe stuff in your API often is some kind of noun, or set of nouns
0:54 and we have resources or URLs that point at these resources, so imagine we're basecamp, we might have users /api/users,
1:03 we might have projects /api/projects, maybe a particular project so /api/project/7 or whatever,
1:12 and then unlike the traditional remote method in vocation type or services
1:16 that are made up of verbs and actions, so things like get users, log in, and so on, we'll see that these http services are built upon nouns.
1:25 And the way that we perform actions on them is with the http verbs, so we might do a get again, /users/one,
1:32 that means give me the details about user number one. Maybe we want to create a new user, so we do a post against /users, things like that,
1:39 so it's the http verbs plus the nouns that are the resources, that together make up our http services.
1:45 Now, most services you run into, kind of stop there, if you are talking about restful services there is a couple more levels
1:51 we got to go into so you might have resource discovery, so APIs like basecamp and other sort of well known APIs github and so on,
2:00 they list exactly what their resources are, but certain types of restful services don't, the just say start here and we'll give you a bunch of URLs
2:09 and then you can explore further, using those URLs, so that is resource discovery. The other thing that we could do but many services don't,
2:18 is content negotiation, at a super low level, maybe you've got a /users/one and you have the ability to either access that
2:26 and get the result back as json or as xml, so if you set the accept type header either in your client or your browser,
2:34 you are going to get whatever you put there, so json gives you json, xml gives you xml, you could even go so far to say
2:41 I accept an image and it will give you the profile image back. But, most services really say you do this request, "you get some json,
2:48 you do that request, you get some xml", it's a little less dynamic but if you talk full restful services, this is typically part of what is included.


Talk Python's Mastodon Michael Kennedy's Mastodon