These days REST APIs are used everywhere for client-server communication. Developers are also adopting GraphQL, but a staggering amount still uses RESTful APIs regularly. REST API uses HTTP methods like the GET, PUT, POST, and DELETE to request a server perform a particular action.
Let’s look at six ground principles of REST API laid down by Dr. Fielding (creator of REST API).
Before we discuss the principle, here is a quick overview of a REST API: REST APIs allow you to perform CRUD (create, read, update, and delete) operations between a client and a server. It connects your backend with your frontend so they can communicate with each other.
The REST API is stateless meaning that every HTTP request happens in complete isolation. When the client makes the HTTP request, it will contain all the necessary information to make the server understand the requests sent from the client.
Both the client and the server are completely autonomous in every way. Their communication will only happen using the REST API. This improves the portability of the codebase across multiple platforms and also helps with making the server scalable.
REST API provides four interfaces to achieve uniformity.
REST API is often made cacheable to improve the performance of the application. It reduces the server load and the client uses the cached response if the user is requesting the same resources. It also dynamically decreases the load time of your application.
REST API relies on layered system architecture where applications are allowed to be more stable by limiting the component behavior. This helps with improving the application security as components in each layer cannot interact beyond the next immediate layer they are in.
This is not a required constraint. It allows a client code to be downloaded and to be used within the application.