Characteristics of REST APIs
REST API stands for Representational State Transfer Application Programming Interface. It is an architectural style and approach to communications often used in web services development. In a client-server connection, REST API recommends creating an object of the data requested by the client and sending the object’s values back to the user.
Characteristics of REST API:
1. Client-Server Architecture: It is built with a client-server architecture meaning that the client sends a request to the server and the server sends back a response. The client can be any device or application that can make HTTP requests, while the server is the application that provides the API and responds to client requests. This characteristic allows for the separation of concerns, making it easier to develop, maintain, and scale both of these components independently.
2. Statelessness: RESTful APIs are stateless, meaning that each request is made by the client to the server. It contains all the information necessary for the server to fulfill the request, without relying on any previous requests or server-side storage. This is why every authenticated REST request has to carry an authentication token in the request headers.
3. Cacheability: It is important to utilize methods to reduce the load on the server. This means that the API responses can be cached by the client, allowing for faster response times in subsequent requests for the same resource. It reduces the load on the server and improves performance, as the server does not need to generate the same response for each request.
4. Authentication: It represents the accessibility for a particular resource such that only the right person having the right permission can access a resource. Authentication at its core has the ability to identify the caller such that it can log a request client id from the server for auditing.
5. Layered System: REST requires the APIs to be designed as a layered system, where the client interacts with the server through a single endpoint. It provides a separation of concerns and makes it easier to add new backend systems, change existing ones, or perform maintenance, without affecting the client.
6. Code-On-Demand: It means that the server can send back code to be executed by the client instead of data. This can help extend the functionality of the client and lead to more dynamic and customizable interactions. However, this also requires that the client can understand and execute the code that the server sends back.
7. Uniform Interface: It means that the API uses a common set of methods, such as GET, POST, PUT, and DELETE, to access resources, and a standard format, such as JSON or XML, for requests and responses. The uniform interface also makes it easier to implement API versioning, as new functionality can be added by defining new resources and methods, without affecting existing ones.