Introduction3:39 with Alena Holligan
Before we can build anything with the REST design pattern, we have to know what REST is and what problems it solves.
REST stands for Representational State Transfer. REST sits on top of HTTP and defines how your API works. Mostly, it's a set of rules for how to use the HTTP framework to access bits and pieces of your application or data in reliable and predictable ways.
Learn more about HTTP Basics
[MUSIC] 0:00 Hi, everyone. 0:09 I'm Alena, one of the teachers here at Treehouse. 0:09 In this course I wanna talk to you about something that 0:11 applies to nearly every modern programming language, REST APIs. 0:15 APIs are one of the most commonly used interfaces for sharing information across 0:19 both internal products and third party data sources, such as Twitter and Google. 0:24 Whether you're building or 0:29 consuming an API, understanding the fundamentals will give 0:30 you a strong foundation before getting started with language specific tools. 0:34 This course will cover terminology and structure of API communication, and 0:39 show you examples of this communication using Postman, a common tool for 0:44 testing API communications. 0:48 REST is really just another later on top of HTTP, the hyper text transfer protocol, 0:52 which is the foundation for all communication on the Internet. 0:58 You'll get the most out of this course if you understand the basics of HTTP. 1:02 You can always review our course on HTTP before you get started, or 1:07 anytime you'd like clarification. 1:12 Look for a link in the teacher's notes. 1:15 When you build a website or app, you´re building a user interface for 1:18 your app's logic and data model. 1:21 The point of an API though, is not to create a traditional user interface, but 1:24 to provide a programmatic interface. 1:29 A code UI, if you will, to that same logic and data model. 1:32 The major difference is that the burden of creating the interface 1:36 is on the users of the API and not the creator. 1:40 Before we talk about REST, 1:43 let's talk about the other funny word in our title, API. 1:46 API stands for Application Programming Interface, 1:50 which is a pretty jargony way of talking about code that makes it easier for 1:53 things outside of an application to interact with that application. 1:58 Why do we want to provide gateways like this? 2:03 Well, quite often, our code is running on one server, or 2:06 even just one kind of server, like a Java Virtual Machine, and 2:09 we need to talk to it from somewhere outside. 2:13 Maybe we have a server running for handling the scores of our game 2:16 from all across the globe and we want to be able to update those scores, 2:20 whether our players are using a PC, a mobile device, or a tablet. 2:24 We could write some sort of bridge or connection layer, but 2:29 we might have to do that for every new device. 2:32 Building a REST API that works with any external client, anywhere on the Internet, 2:35 saves us a lot of headaches. 2:39 REST, our other looming acronym, stands for Representational State Transfer. 2:42 This is yet more tech jargon, but it'll take a bit more time to explain. 2:48 The web is, by design, stateless. 2:53 This means that every request that you make to a website is like meeting that 2:56 site for the first time. 3:00 Imagine if your friends were like this. 3:03 You'd have to introduce yourself each time you spoke in a conversation. 3:05 REST doesn't write this. 3:10 It puts all of the work of remembering state on the client, 3:11 which is your computer program. 3:14 After each request, the server forgets your client entirely. 3:16 In fact, you might not even be talking to the same server each time. 3:21 Your client though, can, and will hold on, to whatever state information it needs, 3:25 like authentication keys or previous endpoints. 3:30 Wait, that's a new word. 3:34 Let's talk more about end points in the next video. 3:35
You need to sign up for Treehouse in order to download course files.Sign up