0
0
Rest APIprogramming~5 mins

Plural vs singular resource names in Rest API - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
Why do REST APIs usually use plural resource names?
Plural resource names represent collections of items, making it clear that the endpoint deals with multiple resources, like /users for many users.
Click to reveal answer
beginner
What does a singular resource name usually represent in REST APIs?
A singular resource name often represents a single item or entity, typically used in the URL when accessing or modifying one specific resource, like /users/123.
Click to reveal answer
beginner
Which is the recommended way to name a resource collection endpoint: /book or /books?
The recommended way is /books because it clearly indicates a collection of book resources.
Click to reveal answer
beginner
How would you name an endpoint to get a single user by ID?
Use the plural resource name followed by the ID, like /users/123, to indicate you want one user from the users collection.
Click to reveal answer
intermediate
Is it okay to mix singular and plural resource names in the same API?
It is best to be consistent and use plural names for collections and singular only when referring to a single resource by ID. Mixing can confuse users and developers.
Click to reveal answer
Which URL is best for accessing all products in a REST API?
A/products
B/product
C/getProducts
D/allproducts
How should you name the endpoint to update a single order with ID 45?
A/order/45
B/orders/update/45
C/orders/45
D/updateOrder/45
Why avoid using singular resource names for collection endpoints?
AThey confuse the meaning of the endpoint
BThey require more server memory
CThey are slower to load
DThey are harder to type
Which is the best practice for REST API resource naming?
AUse uppercase letters in URLs
BUse singular for all endpoints
CUse verbs in resource names
DUse plural for collections and singular for single items
What does the URL /users/789 typically represent?
AA collection of users
BA single user with ID 789
CA search for users
DAn error page
Explain why REST APIs prefer plural resource names for collections and how singular names are used.
Think about how you talk about groups vs. one item in real life.
You got /3 concepts.
    Describe the potential confusion if singular resource names are used for collections in REST APIs.
    Imagine asking for 'book' but getting many books instead.
    You got /3 concepts.