 Hello everyone, today I'll be introducing you what are application programming interfaces. So as in the last video we have seen what is meant by IoT and how to be actually generate and use the architecture of IoT. So in this video I'll be introducing you the APIs that are going to be acting as an attachment to the IoT platform and the architecture. So by the end of this session students will be able to define the concept of API specifically for IoT. These are the outlines. Let us first go through the definition of API and then I'll take you through a quick example just to make you familiar with how an API works in a general scenario. Basically to begin with what is an API just try to recall like what do we actually mean by a subroutine in a computer programming language. You can pause this video for a while and just think on this. Now to proceed ahead subroutine is nothing but a piece of code that is written in a separate portion of a code or a programming language and this piece of code is generally utilized multiple number of times. So any piece of code or any operation like maybe a sort of addition or a simple programming language code which is going to perform an operation like addition, subtraction, multiplication, division or any arithmetic operation which you are going to frequently use again and again. So such kind of codes are actually defined as a functions or methods in any programming language and we simply call them as subroutines and later on whenever we need the task to be performed we simply call them in our main routine. So similar to this one APIs act as a subroutine which can be actually called by the browser of a client who is trying to access some sort of content on a web browser. So let's try to understand what is an application programming interface with the help of a simple example. So as you can see we have a person here who is trying to access a web resource. He is actually trying to access a website maybe let us say that he is trying to access his email by going to the website called Google. And so this is just client number one and you can consider there are other computers and other clients who are actually trying to access this particular website through internet connection. So this is client number one and client number two as you can see. So both these clients are trying to access this particular website. Now for instance let us say that this website is asking for a login. So login in the sense for example just imagine that you are trying to access the Gmail portal of your own username then probably you are first of all prompted to enter your credentials like username and password. So whenever you try to enter the username and password what happens in the back end is that particular URL or so called the uniform resource locator or in short a URL is going to contain the API. And what is this API in turn going to do? For example as I have adopted this particular diagram from a link called restful.io. So it's a folder here it has a website and that website called restful.io has a main directory inside which we have another folder which is named with this particular naming. So whenever I try to access a website I need to simply go through the login part of that particular website. So let's move ahead and see this thing in more detail. So you can imagine now a client is trying to access a website. What he is exactly doing is he is trying to send a request to a server. This server is nothing but a web server maybe let us say it's a Google web server. It is trying to access the request content I mean we are going to look into detail like how this request and response content is going to be elaborated and how to deal with the header information of this one in a short while but just stick to the slide like I am first of all requesting to the web server and web server in turn is going to process this particular request and then it is going to respond me back with some sort of data whatever I'm requesting. So in the due process of this request and response being sent by the server and by the client there are a couple of things that happen. So this is the HTTP request composition. So a request especially the HTTP protocol which is generally used for any kind of online requests or posting kind of information that you try to actually make. All these things actually work under the HTTP protocol which lies in the TCP-IP OSI model. So HTTP actually stands for Hypertext Transfer Protocol which relies on these two things so called request and response cycle. So the request cycle of HTTP is composed of four things. The first one is Uniform Resource Locator like as you can see www.maybegoogle.com that's a URL. Inside this URL I mean inside the frame format of this particular HTTP request you have a second format I mean the second entity which says method. Methods are basically of four types the first method is get the second one is post third one is put and fourth one is delete. I mean these are the four methods which form or which compose this particular HTTP request by mentioning this particular keyword in the method frame of your HTTP request. So depending upon whether you are posting the information to the website or you are requesting some sort of information from the website or you want to modify some content on the website or you want to delete some content on the website. These are the four methods which are allowed by the HTTP request. So we will go through them in detail in a couple of minutes. So similarly the third entity of your HTTP request is known as a header. Header actually contains all the user agents like it would contain what data format is going to be used for transmitting the request and receiving the response. So basically there are two data formats XML and JSON. So we will go through the JSON example in a couple of minutes again. So the fourth entity of this HTTP request is nothing but a body. Body means for example if a client is searching for an image of Internet of Things on Google then whatever image that you actually get in response from the website is nothing but the content of the body. So you can imagine like the body of this particular HTTP request is going to contain all the information which would be displayed probably on the web browser or the web screen. So once we have understood this request now let us see what the server is going to respond by posting this HTTP response composition. Here what we have is the status code. So the response code which is given by the server and posted to the client contains three parts. So the first part is status code. The status code for example if the user is requesting for an IoT image on the Google server and if the Google server while processing if it identifies and if it finds a match then probably it is going to return the code status code inside this HTTP response as a success. For instance if it does not find any match I mean he is trying to access some XYZ kind of an image and that particular XYZ image is not available on the website or so called on the web server then it is going to return status code called 401. So there are a variety of HTML codes we are not going to go into the details but just as an example this is the status code which indicates whether the content is available or it is being matched or not on the web server. The second entity of HTTP response is the header which contains the content type as I have earlier discussed I mean I have quoted that is the content type is going to be either of JSON or XML which is the worldwide used formats nowadays for very quick transmission between the server and the client machine. So I will show you an example again the body contains the actual data like you are whether browsing some sort of web content or some other part. So now before proceeding ahead let us have a quick example of how a JSON appears. So JSON actually stands for JavaScript object notation which is a very simple notation like it has just two things the first one being the key and the second one being the value. So for example if I am talking about the type of PISA I am actually trying to order then the key is going to be CRUST which indicates the type of CRUST I am ordering and what is going to be the value I mean what kind of CRUST I am expecting in my PISA order. So this is the value so I want an original CRUST based PISA. So let's have a small example where there is a client who is trying to access a PISA website and he wants to order certain things by posting the content with the help of a HTTP protocol that happens by default through the browser. So let us say that he has ordered something and if it has to respond I mean the web server has to respond in return to this particular client then probably you need to discuss I mean it's not possible like two people are discussing the question being asked in English and the answer is being given in Chinese. So it is going to create some sort of some kind of noise whether the information is transferred whether the information is general or not if you don't stick to a particular communication media or the standard communication protocol then everything seems to be noise. So just to avoid such kind of situations here we have the same example client is trying to communicate with a server. So this server has to accept I mean there has to be a deal between this client and the server that the formats that both the people are going to share and use has to be either JSON or XML. So what this browser does whenever the client is trying to request the header of the HTTP request format is going to have the content type mentioned as JSON. So it has mentioned something like application slash JSON and in response if server allows the client to talk with a JSON format then probably it is going to return back like content type equals to application slash JSON. So here the deal is finished and henceforth whatever communication happens between the client and the server it is going to happen with a JSON data format. So this is how the communication happens. As an example if we wanted to design an API for our own website by considering the same PISA ordering example this is how it would look like whenever I want to get some data from the website I am going to simply put the IP address of the site like maybe www.example.com slash orders. So whenever my web server finds that I am posting slash orders it is going to show me the list of existing orders which I have already given. Similarly the rest of the things and this is how we actually generate an API. And these are the references that are used for this VPD. Thank you.