4 Designing a RESTful API
This chapter covers
- The constraints that underpin the design principles of REST APIs
- How the Richardson Maturity Model can help us understand the advantages of REST best design principles
- The concept of resource in REST APIs
- Designing API endpoints by combining CRUD with the concept of resource
- Using HTTP verbs and HTTP status codes to design meaningful requests and responses for REST APIs
- Using URL query parameters and request payloads in designing our API endpoints
The concept of Representational State Transfer (REST) was developed by Roy Fielding to describe an architectural style for applications that communicate over a network. Originally, the idea of REST defined a number of constrains that applications need to meet in order to be considered RESTful. Over time, with the increasing popularity of REST, more detailed protocols and specifications have been developed that give us well-defined guidelines about how to design our APIs. Today, REST is by far the most popular choice for the implementation of web APIs. In this chapter, we study the protocols and specifications defined in REST, and we see how we can use them to design the specification for the API of the orders microservice of the CoffeeMesh application.