0
0
Rest APIprogramming~10 mins

Plural vs singular resource names in Rest API - Visual Side-by-Side Comparison

Choose your learning style9 modes available
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.
Execution Sample
Rest API
GET /users
GET /user/123
POST /users
DELETE /user/123
Shows requests using plural for collections and singular for single items.
Execution Table
StepRequestResource NameTypeActionResponse
1GET /usersusersPluralReturn list of users200 OK with user list
2GET /user/123userSingularReturn user with ID 123200 OK with user data
3POST /usersusersPluralCreate new user in collection201 Created
4DELETE /user/123userSingularDelete user with ID 123204 No Content
5GET /useruserSingularMissing ID, error400 Bad Request
💡 Requests stop after response is sent.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5
Resource Nameusersuserusersuseruser
TypePluralSingularPluralSingularSingular
ActionReturn listReturn singleCreate newDelete singleError - missing ID
Response200 OK list200 OK single201 Created204 No Content400 Bad Request
Key Moments - 3 Insights
Why do we use plural names like /users for collections?
Plural names clearly indicate the resource is a collection, so the API returns multiple items, as shown in execution_table rows 1 and 3.
What happens if we use singular without an ID, like GET /user?
The API expects an ID for singular resources. Without it, it returns an error, as seen in execution_table row 5.
Can singular resource names be used for creating new items?
No, creation is done on the collection (plural) endpoint, like POST /users in row 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what type is the resource name 'users' in step 1?
ASingular
BPlural
CUnknown
DBoth
💡 Hint
Check the 'Type' column in execution_table row 1.
At which step does the API return a 400 Bad Request error?
AStep 2
BStep 3
CStep 5
DStep 4
💡 Hint
Look at the 'Response' column for the error status in execution_table.
If we change POST /users to POST /user, what would likely happen?
AReturn an error because singular is for single items
BReturn list of users
CCreate a new user successfully
DDelete a user
💡 Hint
Refer to key_moments about creation using plural resource names.
Concept Snapshot
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.
Full Transcript
This visual execution shows how REST APIs use plural resource names for collections and singular names for single items. The API checks the resource name in the request. If plural, it treats it as a collection and returns or modifies multiple items. If singular with an ID, it handles a single item. Missing IDs on singular resources cause errors. For example, GET /users returns a list, while GET /user/123 returns one user. POST is done on plural to create new items. This helps keep API design clear and consistent.