Concept Flow - Plural vs singular resource names
Client sends request
Check resource name
Plural
Handle as collection
Return response
The API checks if the resource name is plural or singular to decide if it handles a collection or a single item.
GET /users GET /user/123 POST /users DELETE /user/123
| Step | Request | Resource Name | Type | Action | Response |
|---|---|---|---|---|---|
| 1 | GET /users | users | Plural | Return list of users | 200 OK with user list |
| 2 | GET /user/123 | user | Singular | Return user with ID 123 | 200 OK with user data |
| 3 | POST /users | users | Plural | Create new user in collection | 201 Created |
| 4 | DELETE /user/123 | user | Singular | Delete user with ID 123 | 204 No Content |
| 5 | GET /user | user | Singular | Missing ID, error | 400 Bad Request |
| Variable | Start | After 1 | After 2 | After 3 | After 4 | After 5 |
|---|---|---|---|---|---|---|
| Resource Name | users | user | users | user | user | |
| Type | Plural | Singular | Plural | Singular | Singular | |
| Action | Return list | Return single | Create new | Delete single | Error - missing ID | |
| Response | 200 OK list | 200 OK single | 201 Created | 204 No Content | 400 Bad Request |
Use plural resource names (e.g., /users) for collections. Use singular resource names (e.g., /user/123) for single items. POST and GET on plural handle collections. GET, DELETE on singular handle single items. Missing ID on singular causes errors.
/user or /users?/users is the correct plural form./users because it represents multiple users. -> Option D/users [OK]/products/123 uses plural products and includes the ID, which is the common RESTful convention./products/123 -> Option AGET /order
GET /orders
GET /order/456
GET /orders/456
GET /orders uses plural and no ID, so it returns the list of orders. Others either use singular or include an ID, indicating single item access.GET /users/ to get a list of users and GET /user/{id} to get a single user. A developer mistakenly uses GET /user/ to get all users. What is the likely problem?/users/ is correct for all users./user/ is singular and without an ID, so it likely does not exist or returns an error like 404./user/ is incorrect for list retrieval and may cause a 404 error. -> Option AGET /books correctly retrieves all books (plural). GET /book/{id} correctly retrieves a single book (singular with ID).GET /books for all books and GET /book/{id} for a single book -> Option BPass the test and this pattern moves unknown