What is Rest API?
REST means REpresentational State Transfer. REST API is one of the most popular web services accessible these days. It Provides architecture constraints such as stateless communication and cacheable data. They permit the client’s browser to communicate with the server using the HTTP standard methods and provide the current state of the database.

Origin of REST
REST was introduced in 2000 by a man of science Roy Fielding as a part of his Ph.D. treatise. Fielding was conjointly deeply concerned within the early development of the WWW and was a principal author of the world HTTP specification.
How does REST work?
In REST architecture everything is a resource and this can be text, XML, JSON, etc these resources should support common HTTP operation which will be identified by IDs (URL or URI). When the client makes a request to REST API the server will transfer a representation of the state of the requested resource.
Making Request
The client makes a request to get or modify data on the server. Request contains :
HTTP verb – informs which kind of operation wants to perform like
- GET: get specific resource (by id) or a collection of resources
- POST: create a new resource
- PUT: update a specific resource (by id)
- DELETE: remove a specific resource by id
Header and Accept – information about the request which includes MIME accept-type like text/html, application/json, image/jpeg, etc.
Path – path to a resource (e.g. www.domainname.com/customers/223/orders/12 )
Message body – optional message data
Server Response
The server will respond based on the request coming from the client. Response contains:
Header and Content-type – inform the client which type of data server is
responding.
Response code – informs the client about the status of the operation.
common response codes are:
◆ 200 – OK
◆ 201 – CREATED
◆ 400 – BAD REQUEST
◆ 404 – NOT FOUND
◆ 500 – INTERNAL SERVER ERROR
Response body – response data
Example of request-response:

