REST API

What is an API

Definition - API stands for Application Programming Interface and in simple terms it is a layer between the frontend and the backend / Database.

It is a application which does not have any user interface and only returns and accepts data from the database and frontend applications respectively.

Eg - https://reqres.in/api/users?page=1 is a API which returns a array of objects with dummy information about people. Like so -


What is a REST API

There are some rules that a developer need to follow while building a API. Depending on these rules, we can have differnet types of API.

And if a API follows these rules ,Then it is called a REST API -

Although ,there are different types of APIs for eg - SOAP, The REST APIs are by far the most popular choise among developers.


HTTP Requests

An HTTP request is made by a client, to a named host, which is located on a server. The aim of the request is to access a resource on the server. To make the request, the client uses components of a URL (Uniform Resource Locator), which includes the information needed to access the resource.

There are different types of HTTP requests -


How To Make a HTTP request to an API.

There are several in-built and external javascript packages that help you to make HTTP requests to APIs on different routes. Some of these are -

There are many more.


When we use APIs


Benefits of the API calls.


Conclusion

We have covered what APIs are and when to use them in a react application.

APIs are part of back-end engineering and that's why we covered only the most important topics. But , in-fact they are a very vast topic and i suggest you to go through the links in the refferences section for better understanding.


Refferences