0
0
Rest APIprogramming~5 mins

Noun-based resource naming in Rest API - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is noun-based resource naming in REST APIs?
It is a practice of naming API endpoints using nouns that represent resources, such as 'users' or 'products', rather than verbs or actions.
Click to reveal answer
beginner
Why should REST API endpoints use nouns instead of verbs?
Because REST focuses on resources and their state, using nouns makes endpoints clear and consistent, while HTTP methods (GET, POST, etc.) define the actions.
Click to reveal answer
beginner
Example: Which is a better REST API endpoint for retrieving a list of books?<br>1) /getBooks<br>2) /books
The better endpoint is /books because it uses a noun representing the resource. The HTTP GET method is used to retrieve the list.
Click to reveal answer
intermediate
How do you name a REST API endpoint for accessing a single resource?
Use the plural noun for the resource followed by its unique identifier, for example, /users/123 to access the user with ID 123.
Click to reveal answer
intermediate
What is the role of HTTP methods in noun-based resource naming?
HTTP methods like GET, POST, PUT, DELETE define the action to perform on the resource named by the noun in the URL.
Click to reveal answer
Which of the following is the best REST API endpoint for retrieving all orders?
A/getOrders
B/orders
C/fetchOrders
D/orders/get
How should you name an endpoint to update a specific product?
A/products/{id}
B/productUpdate
C/products/update/{id}
D/updateProduct
What HTTP method is typically used with noun-based endpoints to create a new resource?
AGET
BDELETE
CPUT
DPOST
Which URL best follows noun-based resource naming for deleting a user with ID 45?
A/users/delete/45
B/deleteUser/45
C/users/45
D/removeUser?id=45
Why avoid verbs in REST API endpoint names?
ABecause HTTP methods already define actions
BBecause nouns are shorter
CBecause verbs are confusing
DBecause verbs are deprecated
Explain noun-based resource naming in REST APIs and why it is important.
Think about how REST treats resources and actions separately.
You got /4 concepts.
    Describe how you would design REST API endpoints for a blog application using noun-based resource naming.
    Focus on resources as things you can get or change.
    You got /4 concepts.