0
0
Rest APIprogramming~5 mins

Avoiding verbs in URLs in Rest API - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
Why should URLs avoid verbs in REST APIs?
URLs should avoid verbs because REST APIs use HTTP methods (GET, POST, PUT, DELETE) to express actions. URLs represent resources (nouns), making APIs clearer and easier to understand.
Click to reveal answer
beginner
What is a good example of a URL avoiding verbs?
A good URL example is /users/123 to access user data. The action is defined by the HTTP method, like GET to retrieve or DELETE to remove the user.
Click to reveal answer
beginner
What is wrong with this URL: /getUser/123?
It includes a verb 'get' in the URL, which is redundant because the HTTP GET method already means 'retrieve'. This breaks REST principles and can confuse API users.
Click to reveal answer
intermediate
How do HTTP methods relate to avoiding verbs in URLs?
HTTP methods define the action on a resource: GET retrieves, POST creates, PUT updates, DELETE removes. This means URLs only need to name resources, not actions.
Click to reveal answer
intermediate
Give an example of a RESTful URL and HTTP method to update a product.
Use URL /products/456 with HTTP PUT method. The URL identifies the product resource, and PUT tells the server to update it.
Click to reveal answer
Which part of a REST API URL should you avoid?
ANouns like 'users' or 'products'
BVerbs like 'get' or 'update'
CResource IDs like '123'
DQuery parameters
What HTTP method is used to delete a resource?
ADELETE
BGET
CPOST
DPUT
Which URL is more RESTful?
A/createUser
B/deleteUser/123
C/updateUser/123
D/users
How do you update a user with ID 789 in a REST API?
AGET /users/789/update
BPOST /updateUser/789
CPUT /users/789
DDELETE /users/789
Why is '/getOrders' a bad URL in REST?
AIt uses a verb 'get' which is redundant
BIt lacks a resource ID
CIt uses a noun instead of a verb
DIt uses the wrong HTTP method
Explain why REST API URLs should avoid verbs and how HTTP methods relate to this.
Think about how you tell a friend what to do using verbs versus naming things.
You got /4 concepts.
    Describe a RESTful way to design a URL and HTTP method for deleting a product with ID 101.
    Focus on naming the thing and using the right HTTP method for the action.
    You got /4 concepts.