REST API
REST API
Frontend captures all the details entered in the website for hotel
booking & send those data to the API over http protocol.
HTTP Protocol is independent of any languages.
Once API receives this request with data, it will call createReservation()
method
Create reservation requires , first in check in , checkout date, area
where they need to book,no:of rooms it needs this data to run this
method &create reservation book the room
Also data sending to API is in either JSON/XML format(both are
language independent)- These are representation of data in different
format
API again uses JSON/XML format to send response back to frontend.
Frontend will parse the JSON & extract values & add in frontend html
There’s no direct interaction b/w hotels.com & marroitt.com but
through exposing an API
PUT: Put replaces all current representation of the target resource with
uploaded content
Replaces existing resources already present in server
Update information
HTTP methods which are commonly used to communicate with Rest API’s are
POST- A POST request is used to send data to the server, for example, customer
information, file upload, etc. using HTML forms.
PUT- Replaces all current representations of the target resource with the uploaded
content.
DELETE- Removes all current representations of the target resource given by a URI.
Resources:
Resources represent API/Collection which can be accessed from the Server
Google.com/maps
google.com/search
google.com/images
Path Parameters:
Path parameters are variable parts of a URL path. They are typically used to point to
a specific resource within a collection, such as a user identified by ID
https://www.google.com/Images/1123343
https://www.google.com/docs/1123343
https://amazon.com/orders/112
https://www.google.com/search?
q=newyork&oq=newyork&aqs=chrome..69i57j0l7.2501j0j7&sourceid=chrome&ie=
UTF-8
Query Parameters:
Query Parameter is used to sort/filter the resources.
Query Parameters are identified with?””
https://amazon.com/orders?sort_by=2/20/2020
Headers/Cookies:
Headers represent the meta-data associated with the API request and response. In
layman terms, we were sending Additional details to API to process our request.
Example : Authorization details
https://rahulshettyacademy.com/#/index