REST is a way of communicating, using a combination of URL’s and what are called “verbs” to make stuff happen on the internet. You use REST all the time when you surf the web, though most people are only aware of the URL component.
There are four verbs commonly associated with REST Services:
To get a sense of what the rest API is let's first talk about rest. 0:00 Rest stands for representational state transfer and 0:04 is a way of defining how a web server should respond to requests. 0:08 Normally when humans interact with the Internet they use a web browser 0:13 as a client. 0:17 The browser makes a request to the server and HTML and CSS is returned. 0:18 It's human friendly. 0:23 Machines can also make requests to URLs and ask for resources. 0:25 These responses are intended for machines, not humans, so 0:30 no HTML and CSS are returned. 0:33 This type of response is normally formatted in JSON. 0:37 A good example of this is the Twitter app on your phone, 0:41 it makes a request to Twitter's rest API to get the tweets before you see them. 0:44 The JSON from Twitter's API is then formatted and displayed on your phone. 0:49 API is done only allow you to read data but also add update and delete data. 0:53 Each of these actions can be mapped to an HTTP verb post, put or delete. 1:00 By combining an HTTP verb with a URL an API can do many things. 1:05 Such as post tweets, delete emails or even transfer money. 1:11 When a set of URLs are designed to interface with a back end program in this 1:16 way we call it a Rest API, or application programming interface. 1:20 Let's look at the demo user interface for our Rest API again. 1:26 I'll open up the Chrome developer tools and then click on the network tab. 1:30 This will allow us to see what's happening when we use our user interface. 1:36 When we submitted new question like why is the sky 1:42 blue, our UI makes an http post request to the URL slash questions. 1:49 This is via an AJAX call. 1:58 The server responds by inserting a new question into the database and 2:01 returning it back so it can be displayed. 2:05 When we brought an answer up 2:14 The UI posts a request to the URL pattern. 2:21 Questions, question ID, answers, answer ID, vote-up. 2:25 The seven responds by increment in the specified and says vote counts and 2:29 returning the whole question back with it's answers. 2:35 The UI can now be updated. 2:41 Now that we have a sense of what a Rest API is and 2:43 how it works, let's plan the API we want to build the next. 2:46
You need to sign up for Treehouse in order to download course files.Sign up