4 Principles of REST API design
This chapter covers
- The design principles of REST APIs
- How the Richardson Maturity Model helps us understand the advantages of REST best design principles
- The concept of resource in REST APIs
- Designing API endpoints for REST APIs
- Using HTTP verbs and HTTP status codes to create highly expressive REST APIs
- Designing high-quality payloads and URL query parameters for REST APIs
Representational State Transfer (REST) describes an architectural style for applications that communicate over a network. Originally, the concept of REST included a list of constrains for the design of distributed and scalable web applications. Over time, detailed protocols and specifications have emerged that give us well-defined guidelines for designing REST APIs. Today, REST is by far the most popular choice for building web APIs[1]. In this chapter, we study the design principles of REST, and we learn to apply them by designing the orders API of the CoffeeMesh platform, the on-demand coffee-delivery application we introduced in section 1.5.
We explain the concept of resource, and what it means for the design of REST APIs. You’ll also learn to leverage features of the HTTP protocol, such as HTTP verbs and status codes, to create highly expressive APIs. The final part of this chapter covers best practices for designing API payloads and URL query parameters.