REST API & RESTful Web Services Explained | Web Services Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys what's going on is climber tikki and in this video we're going to learn about REST API which stands for representational state transfer application programming interface okay so let's first look at the representational state transfer now some of the simple questions that might come up when you're first starting to understand REST API is what is being represented exactly what is a state and what's being transferred okay so let's look at all these words individually and I hope I can explain what they all mean okay so the word representational means there is a transfer of representations of resources and the resources can be pretty much anything that can be named on internet like user a list of users a photo or a list of photos comments posts articles page video books profile etc to understand how exactly we get a representation of resources let's look at how everyone interacts with webpages why client-server model and the HTTP protocol and we're going to get back to this chart @dm this video and I'm going to explain what all this is at the end okay so here's the HTTP protocol okay you guys should be familiar with an HTTP protocol every time you type a URL in a browser you're sending a request to the web server and the web server responds with a resource so what's important to understand here is every time you type a URL in a browser or click on a webpage link you're sending a request for a specific resource or resources from a web server and what's their response and delivers the request your resource to your browser as in a formal web page or whatever format that the resource is in now this second important point to understand is that webserver doesn't actually deliver the resources it doesn't actually send you the database that it has but rather a representation of that resource in a format that is readable for example HTML or image so think of actual resources physical things located on a web server database or stored in web in a web server hard drive and representations of those resources as copies in either readable format for human being like HTML or image or easy to work with formats for programmers like JSON XML and other formats it's also helpful to think of the whole web as a bunch of resources remember that we always request the resource when clicking on a link or type in a URL no wonder that the URL stands for Uniform Resource locator so let's take a closer look at the URL now ok so if we go to this URL or actually here you can see that the protocol is HTTP which is just the secure HTTP protocol followed by the hostname which is clever techie comm and then we have a path to the resource along with its name so let's go ahead and type in this URL into the browser clever technique com4 /img flowers Lily JPEG and here we are presented with a representation of the resource in an image format and if I check the headers here on the response headers I can see that the content type is in fact an image so that's a representation of the Louis J DG resource in an image format now I've also created a HTML page and if I go to Lily dot HTML this resource is now presented in an HTML format and if I check the headers in fact on the content type response headers you can see that the content type is in fact tags flash HTML and we have some other information about the resource like title gorgeous lily flow'r so that's the representation of the resources and the server responds with a representation resource in whatever format that resource is in and that's what the URL is for it's a Uniform Resource locator and every time you click on a link or Rio or enter the URL in the browser you get resources now now that we understand what the word representational means let's look at the word state so to continue from the Claire we take an example think of clever techy as one big application so when you end on a clever take a website this is one state of the application you get a bunch of links to other pages and and you have a logo and categories presented so that's one state of application whenever I click on a link for example here the application state changes and now we're presented with another resource which is a page with all the other content of that resource and as we click through all these different pages the application chain state keep changing the application state changes to one state to the next and that is what the state means in the representational State transfer now the transfer when the resource gets transferred from the web server if we look at the URL again when the resource gets transferred so we send a request for the resource and we get a representation back and whatever formats resources presented this is what is meant by the word transferred however it can also refer to the transfer the application state when we click on the next link and get transferred to another page so at this point we're ready to understand the whole rest architecture and this is what the whole thing looks like ok notice that I've added the verb plus URL and under verb we'll have get post put and delete now we of course we don't have to type those verbs in a web browser when we're requesting a resource those are just actions that describe what what kind or what type of HTTP requests we're sending to the web server okay so the most common one is get so whenever I go to and type clever techie calm if I check the headers on top here you can see that the that the verb is in fact get and every time I click on a page that's a get request now and that's the most common one whenever you click on a link it's usually you're sending a get request now the post on the other hand is used when when you submit some kind of information when you send a tweet out when you log in with user and password or when you subscribe to a newsletter and as you can see here on the left side I have a newsletter subscription and let's go ahead and I'm going to go ahead and test this out right now I'm going to enter my name and email and click send it to me now and I'm going to I'm going to be redirected to this welcome page and now if I check the headers you can see that the method is post because we have posted information and that's the method that ways that was used by the application okay so let's get in post and the HTTP verbs now now that we understand how the rest works let's look at the rest api okay so as you can see here the rest api is made up of a rest api endpoint URL this is where the actual URL is located the API URL is located then we follow that by the method and parameters so the think of the API its sense for the application programming interface but you can think of it as a bunch of useful methods or functions and the parameters are the parameters that we can pass on to these methods just like in a programming language to get what we want out of it so in this example you can see I'm using a Flickr comm API which is an image gallery site I'm using their method to get information about a specific photo named Flickr that photos that get info and for the parameter I'm using photo underscore ID and I'm specifying the idea of the photo and the server is going to send back a response which is going to be the representation of the resource in all the available formats now when we're using REST API it's important to remember that we're not going to be getting HTML as a response because that's not going to be very useful in a programming whenever we're writing our own programming applications and these are the most common formats that we're going to be seeing the representation of the resource whenever sending a REST API request ok so that's how the REST API works now let's actually look at let me show you an example of the REST API request so if I go to Flickr comm services API this is their API documentation and if I scroll down here on the request formats you can see rest and they give you the endpoint URL and how to actually send the request they also have a bunch of functions or API and methods on the right hand side but to make things easier I'm actually going to go to a cool site called API G comm forward slash console and this is a website that already lists a bunch of available api's if you check this checkbox here or scroll box I'm going to go ahead and under API I'm going to check I'm going to select Flickr and under the API and methods it's going to list all the of their methods just like listed in their documentation and under photos I'm going to find the one to search for a bunch of photos which is Flickr that photos that search so that's the method and you can see that it added the endpoint URL along with a method now let's specify some parameters or arguments as you can see the AAP is it required and this is so that that you can track how many requests we're making to their API so that we don't spam it to death so usually you have to sign up for the account but I already signed up and I'm going to use my API key here and you guys feel free to use this API if you feel like typing it otherwise sign up with flicker a yahoo account because the Alko is the one that owns flicker so that's going to be one of our parameters as you can see it added this parameters here in the URL finally actually for the format I'm going to input JSON which is the format that we're going to be getting the response in and for the text I'm going to enter Lily to keep the valentines flower theme going here and finally don't forget to change this HTTP to HTTPS otherwise it's not going to work because it's supposed to be secure and then click send now we got the response back with HTTP 200 okay code which means everything went well and if you scroll down it's going to have a bunch of this JSON code which goes on what seems like forever but if you triple click on it and copy then you can open up the notepad and you can paste the whole thing in a notepad so what we get here is a bunch of results with information about the photos about Lily photos that we just searched for and the reason it's in this strange-looking format is because this makes it a lot easier to implement in our applications as we're going to be programming and using this API and that's what the REST API is for is for implementing into the applications but if you guys want to understand what's going on here a little bit more you can actually paste this inside of a online JSON parser so if you go to json dot parse clear that online that FR you can paste this code here and get rid of the the closing bracket here and just get rid of a part as well so just delete that and now we get presented with the JSON which is a lot easier for us to read so this is just a way to understand all the gibberish and presented by the JSON response a little bit better and you can see that we have information about the photos we have a photo ID we have an owner ID we have a secret key as well as the title of the photo so we can use this code to plug it into into our application and start working with it so that's how we make a get REST API request now let me show you how to make a tweet so if you select Twitter under the api's here it's going to change to the Twitter API and of course whenever we send a tweet out via post method it's going to require authentication so under authentication I'm going to select oh the first one and then sign in with Twitter I'm going to authorize the app and it has logged in to my Twitter account now I'm going to select under tweet I'm going to select the statuses update that JSON which is the method used to post tweets and then I'm going to say happy Valentine's Day under this status and I think that's pretty much all you need click send HTTP to con it okay that means the tweet has been sent let's go to Twitter comm to see if that worked and I'm going to click on my home home page link let's see I'm going to click on my end there you go happy Valentine's Day the tweet has been sent successfully using the REST API so that's pretty much it for the rest API I hope you guys found this video useful and if you did please like share and subscribe and I'll see you next time clever take it out
Info
Channel: Clever Techie
Views: 972,810
Rating: undefined out of 5
Keywords: what is rest api, rest api, restful web services, rest api example, restful web services tutorial, rest, restful, rest api definition, rest api meaning, what is rest service, meaning of rest, what is a rest api, rest endpoint, rest endpoint url, rest tutorial, what is rest web service, what is rest services, rest api tutorial, rest vs restful, rest api client, rest endpoint example, restful web api, resstful api
Id: LooL6_chvN4
Channel Id: undefined
Length: 15min 32sec (932 seconds)
Published: Tue Feb 14 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.