The very first thing a project usually starts with is a definition of the operations the API will expose. According to the REST principles, an operation is exposed by an HTTP method and a URI. The action performed by each operation should not contradict the natural meaning of its HTTP method. The following table specifies the operations of our API in detail:
Method | URI | Description |
GET | /category | Retrieves all available categories in the catalog. |
GET | /category/{category-id}/ | Retrieves all the items available under a specific category. |
GETÂ | Â /category/{category-id}/{item-id}Â | Retrieves an item by its ID under a specific category. |
POST | /category |
Creates a new category; if it exists, it will update it. |
POSTÂ | /category/{category-id}/ |
Creates a new item in a specified category. If the item exists, it will update it. |
PUTÂ | ... |