API: An API is an application programming interface and that helps two different software's to communicate and exchange data with each other. For example: You click “add to cart;” an API tells the site you added a product to your cart; the website puts the product in your cart, and your cart is updated.
It is an action to the structure of API and it refers to representational state transfer. The WWW is an example .HTTP is a protocol used for communication, usually used to communicate with internet resources or any application with a web browser client. Developers follow certain set of rules when constructing the API. For example: one rule states that linking to a URL should return some information. Each URL is known as REQUEST whereas the data sent back is known as RESPONSE.
Consider API is a language like GET,PUT,POST,DELETE whereas REST as librarian to transfer the given request back and forth.
REST API: The client makes the request, the REST API receives the request, gather and process the data and return the data and response to the client.
When you are trying to find videos about Mission Impossible on YouTube. You open up You tube, type Mission Impossible, hit enter and you see a list of videos. Likewise REST API works. You search for something and you get a list of results back from the service you are requesting from
Request is made up of four things. They are
ENDPOINT: There are two key parts to an endpoint that are used when making an API request. One of which is the URL. Big Commerce uses https://api.abc.com/stores/ as the URL for all API Requests. you will receive a 404 error message because it is not a complete endpoint. The second part is the path. Lets think of it like an automatic answering machine that asks you to press 1 for a service, press 2 for another service, 3 for yet another service and so on. For example, lets continue with above example of big commerce, we are going to use the product path which is /v3/catalog/products.
When we put these two parts together, we get a complete endpoint
2. METHOD: The method is a type of request you sent to the server. There are five methods. They are GET,POST,PUT,PATCH,DELETE. Lets try to understand from this example,
When you want to know the Credit card balance on your account, you go to your bank account ,after entering the credentials ,you will click on credit card statement icon, it shows the current balance amount which is a GET method(retrieving the data only). You can pay off either the full current balance or minimum due amount by entering the amount in the amount field which is called as POST method, here you are creating a new amount in the field. If you want to update the minimum due amount here comes the PUT method whereas if you want to modify the payment due date which is called as PATCH method. When you no longer wish to receive any emails form you bank account ,you unsubscribe which is a consider here as DELETE method.
3.HEADER: Headers are used to provide information to client and server which is called as request header and response header. The client manages the user interface concerns whereas the server manages to store data. You will have to set the request headers when you are sending the request for testing an API and you will have to set the assertion against the response headers to ensure that right headers are being returned. It can be used for many purposes like for Authentication.
4.DATA:The data (sometimes called “body” or “message”) contains information you want to be sent to the server. This option is only used with POST, PUT, PATCH or DELETE requests.
You wouldn’t allow anyone to access your bank account without your permission, would you? The same way developers put a bar behind the authentication wall. You can authenticate in two ways: one is by providing username and password and the other one is by creating secret token. The secret token method includes oAuth, which lets you to authenticate yourself with social media networks .
To Wrap Up:
The REST API receive the request, process the data and send responses. It does not care who the client unless until the client follows the rules. Anyone can interact with REST API , unless the REST API includes an authentication layer or similar access restrictions. Most REST API has strict limits that who can access, which capabilities are granted and how many request they can make in a set period.