1 00:00:00,000 --> 00:00:04,145 Think about the web applications you interact with on a daily basis. 2 00:00:04,145 --> 00:00:08,330 We use applications for huge variety of things, but at their simplest, 3 00:00:08,330 --> 00:00:12,251 many follow a common pattern, create, read, update and delete. 4 00:00:12,251 --> 00:00:15,751 Take a blog or a popular social media site, for example. 5 00:00:15,751 --> 00:00:20,020 You can usually make a new post, that's create, view other posts, 6 00:00:20,020 --> 00:00:25,115 that's read, edit a post, that's update, or delete a post, that's delete. 7 00:00:25,115 --> 00:00:30,091 This pattern is commonly known by the acronym CRUD, create, read, update and 8 00:00:30,091 --> 00:00:30,696 delete. 9 00:00:30,696 --> 00:00:35,512 REST APIs allow a client to manipulate data using actions that map closely to 10 00:00:35,512 --> 00:00:36,649 the idea of CRUD. 11 00:00:36,649 --> 00:00:40,234 These actions are get, post, put and delete. 12 00:00:40,234 --> 00:00:45,776 Get, post, put, and delete are known as HTTP verbs or HTTP methods. 13 00:00:45,776 --> 00:00:48,087 There are actually many more HTTP methods, but 14 00:00:48,087 --> 00:00:51,797 we'll concentrate on these four because they're the most commonly used. 15 00:00:51,797 --> 00:00:55,713 See the teacher's notes if you want to learn more about HTTP protocol, but 16 00:00:55,713 --> 00:00:59,891 basically it's an agreed upon standard for communication over the Internet. 17 00:00:59,891 --> 00:01:04,301 Information in a REST API is typically organized using nouns that describe 18 00:01:04,301 --> 00:01:08,851 what the data represents, nouns like users, posts, movies, or recipes. 19 00:01:08,851 --> 00:01:13,785 Using HTTP methods and API nouns, a client can tell a REST API what information 20 00:01:13,785 --> 00:01:17,246 it wants and what it wants to do with that information. 21 00:01:17,246 --> 00:01:21,865 As an example, If the client sends a get request to the resource/movies, 22 00:01:21,865 --> 00:01:26,651 it means it expects to read or view data representing a collection of movies. 23 00:01:26,651 --> 00:01:29,911 A post request means it wants to create a new movie. 24 00:01:29,911 --> 00:01:33,310 Put means it wants to update an existing movie, and 25 00:01:33,310 --> 00:01:36,957 delete means it wants to, you got it, delete a movie. 26 00:01:36,957 --> 00:01:38,174 When we write an API, 27 00:01:38,174 --> 00:01:43,056 we're essentially programming responses to various HTTP requests for resources. 28 00:01:43,056 --> 00:01:45,919 Through code, we say to our express application, 29 00:01:45,919 --> 00:01:49,249 when a client makes a get request to the resource/movies, 30 00:01:49,249 --> 00:01:52,393 respond with a JSON object containing a list of movies. 31 00:01:52,393 --> 00:01:55,489 At the core, that's really all an express API does. 32 00:01:55,489 --> 00:01:59,090 It takes in requests, and responds with JSON objects. 33 00:01:59,090 --> 00:02:02,948 I've just thrown a lot at you that may seem unfamiliar, but stick with it. 34 00:02:02,948 --> 00:02:03,828 In the next video, 35 00:02:03,828 --> 00:02:07,240 we'll build a simplified example of how this all comes together in code. 36 00:02:07,240 --> 00:02:08,494 Are you ready?