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