REST API
REST API is a way of accessing web services in a simple and flexible way without having any processing.
What is Rest API?
An API, or application programming interface, is a set of rules that define how applications or devices can connect to and communicate with each other. A REST API is an API that conforms to the design principles of the REST, or representational state transfer architectural style.
How do Rest APIs work?
REST APIs communicate via HTTP requests to perform standard database functions like creating, reading, updating, and deleting records (also known as CRUD) within a resource.
Following are the main components of Rest API:
- URL - It is the endpoint that needs to be called.
- Method- There are 2 main methods used i.e. GET, POST.
- Params- If the method is GET and we need to pass some data o server hen it can be passed by adding params.
- Headers - Headers contain additional information about request.
- Authorization- Authorization keys and password.
- Body- Data to be sent to server. Generally, in JSON form
Process of integrating an API
- Decide he structure of the API.
- Once the API is developed and deployed, test the API thoroughly in POSTMAN.
- Create a method in rest_connection.js with your api name.
- Add the API path in method object of RestConnectionCls.
- The common method which is called to fetch the data is restFetch.
Notes:
- Test an API in the Network tab of the Inspect.
- You can see url,Payload and Response there.