Introduction
As the name suggests, REpresentational State Transfer (REST) calls for segregating your API into logical resources, which can be accessed and manipulated using HTTP requests, where each request consists of a method out of GET, POST, PUT, PATCH, and DELETE (there can be more, but these are the ones used the most). Each of these methods has a specific meaning. One of the key implied principles of REST is that the logical grouping of resources should be easily understandable and, hence, provide simplicity along with portability.
Up until now in this book, we have used a resource called Product. Let's see how we can logically map our API calls to the resource segregation:
GET /products/1
: This gets the product with ID1
GET /products
: This gets the list of productsPOST /products
: This creates a new productPUT /products/1
: This updates the product with ID1
PATCH /products/1
: This partially updates the product with ID1
DELETE /products/1
: This deletes the product with ID1