1 00:00:00,000 --> 00:00:08,821 [MUSIC] 2 00:00:08,821 --> 00:00:12,559 >> Hey, I'm Treasure, a JavaScript developer and teacher here at Treehouse. 3 00:00:12,559 --> 00:00:16,965 In this course, we'll be using the popular Node.js platform and 4 00:00:16,965 --> 00:00:21,699 Express framework to build a type of web application called a REST API. 5 00:00:21,699 --> 00:00:25,569 To define a REST API, we first need to talk about a traditional web application. 6 00:00:25,569 --> 00:00:30,315 Traditional web applications handle both serverside and clientside concerns. 7 00:00:30,315 --> 00:00:34,244 Say you build a web application to keep a record of your favorite recipes. 8 00:00:34,244 --> 00:00:37,944 To view a certain recipe, you'd click on that recipe's URL, and 9 00:00:37,944 --> 00:00:40,995 your browser would request that recipe from a server. 10 00:00:40,995 --> 00:00:45,701 A traditional server side application would respond to that request by finding 11 00:00:45,701 --> 00:00:50,054 the RESP data in a database, assembling that data into HTML templates and 12 00:00:50,054 --> 00:00:53,298 sending that HTML back to the browser to be displayed. 13 00:00:53,298 --> 00:00:57,759 Seems reasonable but what if you wanted to use that same RESP information to build 14 00:00:57,759 --> 00:01:01,130 a mobile app or an entirely different application? 15 00:01:01,130 --> 00:01:05,770 That's where REST API comes in, when you request a specific recipe in a RESTful 16 00:01:05,770 --> 00:01:09,550 application, the application responds only with the recipe data, 17 00:01:09,550 --> 00:01:11,830 typically in the form of JSON. 18 00:01:11,830 --> 00:01:16,770 Sending JSON data rather than HTML means the back end only has to be built once. 19 00:01:16,770 --> 00:01:20,330 While any number of front end applications can consume and display the data. 20 00:01:20,330 --> 00:01:22,853 When designing an application this way, 21 00:01:22,853 --> 00:01:25,890 you can manipulate the same data in endless ways. 22 00:01:25,890 --> 00:01:30,609 If I have a REST API for recipes, for example, I could create a recipe website. 23 00:01:30,609 --> 00:01:33,880 But I could also use the same data to create a meal planning app, 24 00:01:33,880 --> 00:01:37,168 a calorie tracking app, a virtual cookbook, and on, and on. 25 00:01:37,168 --> 00:01:40,860 As another good example, think about the Twitter app on your phone. 26 00:01:40,860 --> 00:01:43,868 The phone app makes a request to Twitter RESP API, 27 00:01:43,868 --> 00:01:46,168 to get the tweets before you see them. 28 00:01:46,168 --> 00:01:50,739 The JSON from Twitter's API is then formatted and displayed on your phone. 29 00:01:50,739 --> 00:01:54,525 But the Twitter API allows the same tweet data to be accessed and 30 00:01:54,525 --> 00:01:57,890 used by a web browser, a smart TV, or a home IoT device. 31 00:01:57,890 --> 00:02:02,564 REST APIs can provide data and content for rich web applications, mobile apps, 32 00:02:02,564 --> 00:02:04,765 and other serverside applications, 33 00:02:04,765 --> 00:02:08,698 even those applications written in other programming languages. 34 00:02:08,698 --> 00:02:11,517 Basically, a REST API lets you retrieve data and 35 00:02:11,517 --> 00:02:15,730 present that data in any way you want, providing amazing flexibility. 36 00:02:15,730 --> 00:02:19,492 I'll review some key concepts in this course, but to be successful, 37 00:02:19,492 --> 00:02:22,042 you should be familiar with the basics of node, 38 00:02:22,042 --> 00:02:26,220 building a serverside application with Express, and Express middleware. 39 00:02:26,220 --> 00:02:29,408 You should also be familiar with asynchronous JavaScript, 40 00:02:29,408 --> 00:02:32,729 specifically using Callbacks, Promises, and Async Await. 41 00:02:32,729 --> 00:02:36,485 See the teacher's notes below for the prerequisite courses. 42 00:02:36,485 --> 00:02:38,683 In this course, we'll use Node and 43 00:02:38,683 --> 00:02:43,233 Express to build out a simple API that provides data about famous quotes. 44 00:02:43,233 --> 00:02:47,450 When we're finished, users will be able to request famous quotes from our API, 45 00:02:47,450 --> 00:02:50,799 as well as add new quotes, edit and delete existing quotes, and 46 00:02:50,799 --> 00:02:52,120 request a random quote. 47 00:02:52,120 --> 00:02:56,250 As we build this project, you'll learn more about how API's work and 48 00:02:56,250 --> 00:02:59,051 specifically, how to build one with Express. 49 00:02:59,051 --> 00:03:02,047 Let's dig a bit more into the structure of an API.