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?
✗ Incorrect
Using the noun 'orders' as the endpoint with the GET method is the correct RESTful approach.
How should you name an endpoint to update a specific product?
✗ Incorrect
Use the noun 'products' with the product ID and the HTTP PUT method to update the resource.
What HTTP method is typically used with noun-based endpoints to create a new resource?
✗ Incorrect
POST is used to create a new resource at the noun-based endpoint.
Which URL best follows noun-based resource naming for deleting a user with ID 45?
✗ Incorrect
Use the noun 'users' with the ID and the HTTP DELETE method to delete the resource.
Why avoid verbs in REST API endpoint names?
✗ Incorrect
HTTP methods like GET, POST, PUT, DELETE define the action, so endpoints should use nouns to represent resources.
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.