A REST API (or RESTful API) is an application programming interface that is in accordance with Representational State Transfer (REST) architectural style. REST APIs communicate via HTTP requests to perform standard database operations. These include creating, reading, updating and deleting (CRUD functions) within a resource. A RESTful system consists of a client who requests resources and a server who has the resources.

REST architectural constraints

REST defines a set of constraints for creating web services. Its goal is to increase performance, scalability, simplicity, modifiability, visibility, portability and reliability. To achieve this and to be considered RESTful, REST APIs need to be in line with six REST constraints:

  • Uniform interface

To simplify the architecture, all components need to follow the same rules when communicating with each other.

  • Client-server decoupling 

The client and server applications have to be completely independent of each other. The client does not need to know anything about the resource storage and the server does not need to know anything about the frontend UI and user state.

  • Statelessness

Each request needs to include all the information necessary for processing it. Server applications are not allowed to store any data related to client requests.

  • Cacheability

To improve the performance on the client-side and scalability on the server-side, the resources should be cacheable on one or both sides.

  • Layered system

REST APIs must be designed in a way that both client and server cannot tell whether they communicate with the end application or an intermediary, despite the number of layers.

  • Code on demand (optional)

In cases where REST API responses contain executable code, this code should only run on-demand.

Developers can implement REST in various ways. Unlike some APIs imposing strict frameworks, the REST APIs can be developed in different languages, and support a variety of data formats. Due to this flexibility, REST APIs have become a common method of connecting components and applications in a microservice architecture.