Bird
Raised Fist0
Rest APIprogramming~5 mins

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

Choose your learning style10 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.

      Practice

      (1/5)
      1. Which of the following URLs follows the best practice of avoiding verbs in REST API design?
      easy
      A. /createUser
      B. /getUser/123
      C. /deleteUser/123
      D. /users/123

      Solution

      1. Step 1: Understand URL naming conventions

        REST APIs should use nouns to represent resources, not verbs. URLs like /users/123 represent a user resource with ID 123.
      2. Step 2: Identify verbs in URLs

        URLs like /getUser/123, /createUser, and /deleteUser/123 contain verbs (get, create, delete), which is against best practice.
      3. Final Answer:

        /users/123 -> Option D
      4. Quick Check:

        Use nouns in URLs = /users/123 [OK]
      Hint: Use nouns for URLs, verbs go in HTTP methods [OK]
      Common Mistakes:
      • Including verbs like 'get' or 'delete' in the URL
      • Using action words instead of resource names
      • Confusing HTTP methods with URL paths
      2. Which HTTP method should be used with the URL /orders/456 to update an existing order?
      easy
      A. PUT
      B. POST
      C. DELETE
      D. GET

      Solution

      1. Step 1: Match HTTP methods to actions

        GET retrieves data, POST creates new data, PUT updates existing data, DELETE removes data.
      2. Step 2: Identify update action

        To update an existing order at /orders/456, the correct HTTP method is PUT.
      3. Final Answer:

        PUT -> Option A
      4. Quick Check:

        Update = PUT [OK]
      Hint: PUT updates, POST creates, GET reads, DELETE removes [OK]
      Common Mistakes:
      • Using POST to update instead of create
      • Using GET to modify data
      • Confusing PUT and DELETE methods
      3. Given the REST API call: DELETE /products/789, what is the expected action?
      medium
      A. Delete product with ID 789
      B. Create a new product with ID 789
      C. Retrieve product with ID 789
      D. Update product with ID 789

      Solution

      1. Step 1: Understand HTTP DELETE method

        DELETE is used to remove a resource identified by the URL.
      2. Step 2: Apply to given URL

        The URL /products/789 identifies product 789, so DELETE removes it.
      3. Final Answer:

        Delete product with ID 789 -> Option A
      4. Quick Check:

        DELETE removes resource = Delete product with ID 789 [OK]
      Hint: DELETE method removes resource at URL [OK]
      Common Mistakes:
      • Thinking DELETE retrieves data
      • Confusing DELETE with POST or PUT
      • Assuming URL contains action verbs
      4. Identify the error in this REST API design: POST /updateUser/123
      medium
      A. User ID should not be in the URL
      B. HTTP method POST cannot be used with user resources
      C. URL contains a verb 'update', which should be avoided
      D. URL should end with a question mark

      Solution

      1. Step 1: Check URL naming conventions

        URLs should use nouns to represent resources, not verbs like 'update'. The verb should be expressed by the HTTP method.
      2. Step 2: Analyze the given URL

        The URL /updateUser/123 contains the verb 'update', which violates REST best practices.
      3. Final Answer:

        URL contains a verb 'update', which should be avoided -> Option C
      4. Quick Check:

        Verbs in URL = URL contains a verb 'update', which should be avoided [OK]
      Hint: Avoid verbs in URLs; use HTTP methods for actions [OK]
      Common Mistakes:
      • Putting verbs like 'update' in URLs
      • Misusing HTTP methods
      • Ignoring resource identification in URLs
      5. You want to design a REST API to manage blog posts. Which URL and HTTP method combination correctly avoids verbs in the URL and uses HTTP methods properly to delete a post with ID 321?
      hard
      A. DELETE /deletePost/321
      B. DELETE /posts/321
      C. POST /posts/321/delete
      D. GET /posts/delete/321

      Solution

      1. Step 1: Identify correct URL structure

        The URL should use a noun representing the resource, here /posts/321, without verbs like 'delete'.
      2. Step 2: Match HTTP method to action

        To delete a resource, use the DELETE method with the resource URL.
      3. Final Answer:

        DELETE /posts/321 -> Option B
      4. Quick Check:

        Delete resource = DELETE + noun URL [OK]
      Hint: Use DELETE method with noun URL to remove resource [OK]
      Common Mistakes:
      • Including verbs like 'delete' in the URL
      • Using GET or POST for delete actions
      • Placing action words after resource ID
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard