1 00:00:00,000 --> 00:00:09,340 [MUSIC] 2 00:00:09,340 --> 00:00:09,880 Hi, everyone. 3 00:00:09,880 --> 00:00:11,871 I'm Alena, one of the teachers here at Treehouse. 4 00:00:11,871 --> 00:00:15,325 In this course I wanna talk to you about something that 5 00:00:15,325 --> 00:00:19,740 applies to nearly every modern programming language, REST APIs. 6 00:00:19,740 --> 00:00:24,220 APIs are one of the most commonly used interfaces for sharing information across 7 00:00:24,220 --> 00:00:29,720 both internal products and third party data sources, such as Twitter and Google. 8 00:00:29,720 --> 00:00:30,820 Whether you're building or 9 00:00:30,820 --> 00:00:34,100 consuming an API, understanding the fundamentals will give 10 00:00:34,100 --> 00:00:39,140 you a strong foundation before getting started with language specific tools. 11 00:00:39,140 --> 00:00:44,280 This course will cover terminology and structure of API communication, and 12 00:00:44,280 --> 00:00:48,990 show you examples of this communication using Postman, a common tool for 13 00:00:48,990 --> 00:00:50,635 testing API communications. 14 00:00:52,050 --> 00:00:58,380 REST is really just another later on top of HTTP, the hyper text transfer protocol, 15 00:00:58,380 --> 00:01:02,310 which is the foundation for all communication on the Internet. 16 00:01:02,310 --> 00:01:07,640 You'll get the most out of this course if you understand the basics of HTTP. 17 00:01:07,640 --> 00:01:12,970 You can always review our course on HTTP before you get started, or 18 00:01:12,970 --> 00:01:15,230 anytime you'd like clarification. 19 00:01:15,230 --> 00:01:16,960 Look for a link in the teacher's notes. 20 00:01:18,030 --> 00:01:21,830 When you build a website or app, you´re building a user interface for 21 00:01:21,830 --> 00:01:24,590 your app's logic and data model. 22 00:01:24,590 --> 00:01:29,480 The point of an API though, is not to create a traditional user interface, but 23 00:01:29,480 --> 00:01:32,370 to provide a programmatic interface. 24 00:01:32,370 --> 00:01:36,620 A code UI, if you will, to that same logic and data model. 25 00:01:36,620 --> 00:01:40,330 The major difference is that the burden of creating the interface 26 00:01:40,330 --> 00:01:43,860 is on the users of the API and not the creator. 27 00:01:43,860 --> 00:01:46,039 Before we talk about REST, 28 00:01:46,039 --> 00:01:50,692 let's talk about the other funny word in our title, API. 29 00:01:50,692 --> 00:01:53,865 API stands for Application Programming Interface, 30 00:01:53,865 --> 00:01:58,234 which is a pretty jargony way of talking about code that makes it easier for 31 00:01:58,234 --> 00:02:02,410 things outside of an application to interact with that application. 32 00:02:03,500 --> 00:02:06,120 Why do we want to provide gateways like this? 33 00:02:06,120 --> 00:02:09,530 Well, quite often, our code is running on one server, or 34 00:02:09,530 --> 00:02:13,400 even just one kind of server, like a Java Virtual Machine, and 35 00:02:13,400 --> 00:02:16,720 we need to talk to it from somewhere outside. 36 00:02:16,720 --> 00:02:20,140 Maybe we have a server running for handling the scores of our game 37 00:02:20,140 --> 00:02:24,640 from all across the globe and we want to be able to update those scores, 38 00:02:24,640 --> 00:02:29,080 whether our players are using a PC, a mobile device, or a tablet. 39 00:02:29,080 --> 00:02:32,609 We could write some sort of bridge or connection layer, but 40 00:02:32,609 --> 00:02:35,300 we might have to do that for every new device. 41 00:02:35,300 --> 00:02:39,844 Building a REST API that works with any external client, anywhere on the Internet, 42 00:02:39,844 --> 00:02:41,390 saves us a lot of headaches. 43 00:02:42,510 --> 00:02:48,350 REST, our other looming acronym, stands for Representational State Transfer. 44 00:02:48,350 --> 00:02:52,460 This is yet more tech jargon, but it'll take a bit more time to explain. 45 00:02:53,470 --> 00:02:56,272 The web is, by design, stateless. 46 00:02:56,272 --> 00:03:00,716 This means that every request that you make to a website is like meeting that 47 00:03:00,716 --> 00:03:03,180 site for the first time. 48 00:03:03,180 --> 00:03:05,320 Imagine if your friends were like this. 49 00:03:05,320 --> 00:03:09,060 You'd have to introduce yourself each time you spoke in a conversation. 50 00:03:10,060 --> 00:03:11,430 REST doesn't write this. 51 00:03:11,430 --> 00:03:14,830 It puts all of the work of remembering state on the client, 52 00:03:14,830 --> 00:03:16,980 which is your computer program. 53 00:03:16,980 --> 00:03:21,220 After each request, the server forgets your client entirely. 54 00:03:21,220 --> 00:03:25,110 In fact, you might not even be talking to the same server each time. 55 00:03:25,110 --> 00:03:30,420 Your client though, can, and will hold on, to whatever state information it needs, 56 00:03:30,420 --> 00:03:34,150 like authentication keys or previous endpoints. 57 00:03:34,150 --> 00:03:35,980 Wait, that's a new word. 58 00:03:35,980 --> 00:03:38,260 Let's talk more about end points in the next video.