Bird
Raised Fist0
Rest APIprogramming~20 mins

Noun-based resource naming in Rest API - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
RESTful Resource Naming Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the correct RESTful URL for accessing a single user resource?
Given a REST API that manages users, which URL correctly follows noun-based resource naming conventions to access the user with ID 42?
A/user/get/42
B/getUser?id=42
C/users/42
D/users/getUser/42
Attempts:
2 left
💡 Hint
Focus on using plural nouns and hierarchical paths without verbs.
❓ Predict Output
intermediate
2:00remaining
Which URL correctly represents a collection of blog posts?
You want to design a REST API endpoint to retrieve all blog posts. Which URL follows noun-based resource naming best practices?
A/posts
B/getPosts
C/post/list
D/posts/getAll
Attempts:
2 left
💡 Hint
Use plural nouns without verbs or actions in the URL path.
🔧 Debug
advanced
2:00remaining
Identify the error in this RESTful URL design
Which option shows a RESTful URL that violates noun-based resource naming conventions by including a verb in the path?
A/orders/delete/123
B/orders/123
C/orders/123/items
D/orders/123/items/456
Attempts:
2 left
💡 Hint
RESTful URLs should avoid verbs in the path; HTTP methods indicate actions.
🧠 Conceptual
advanced
2:00remaining
What is the best URL to access comments for a specific blog post?
You have blog posts and each post has comments. Which URL correctly uses noun-based resource naming to get comments for post with ID 10?
A/comments?postId=10
B/posts/10/comments
C/getCommentsForPost/10
D/posts/comments/10
Attempts:
2 left
💡 Hint
Use nested resources with plural nouns in hierarchical order.
❓ Predict Output
expert
2:00remaining
How many items are in the resulting resource collection?
Assume a REST API endpoint /products returns a JSON array of products. The response is:
[{"id":1,"name":"Pen"},{"id":2,"name":"Notebook"},{"id":3,"name":"Eraser"}]
How many items does this collection contain?
A0
B1
C2
D3
Attempts:
2 left
💡 Hint
Count the number of objects inside the JSON array.

Practice

(1/5)
1. Which of the following is the best example of a noun-based resource name for a REST API endpoint that manages multiple books?
easy
A. /fetchBooks
B. /getBooks
C. /bookAction
D. /books

Solution

  1. Step 1: Understand noun-based resource naming

    Noun-based naming uses plural nouns to represent collections of resources, making the API intuitive.
  2. Step 2: Identify the correct plural noun path

    Among the options, only '/books' is a plural noun representing the resource collection without verbs or actions.
  3. Final Answer:

    /books -> Option D
  4. Quick Check:

    Noun-based resource = /books [OK]
Hint: Use plural nouns without verbs for resource paths [OK]
Common Mistakes:
  • Including verbs like 'get' or 'fetch' in the URL
  • Using singular nouns for collections
  • Adding action words in resource names
2. Which of the following is the correct REST API endpoint syntax for accessing a single user resource by ID?
easy
A. /users/get/123
B. /user?id=123
C. /users/123
D. /getUser/123

Solution

  1. Step 1: Review REST API syntax for single resource

    Single resources are accessed by appending the resource ID to the plural noun path.
  2. Step 2: Identify the correct syntax

    Option '/users/123' correctly uses the plural noun 'users' followed by the ID without verbs or query parameters.
  3. Final Answer:

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

    Single resource path = /users/123 [OK]
Hint: Use /resourceName/{id} for single resource access [OK]
Common Mistakes:
  • Adding verbs like 'get' in the path
  • Using query parameters instead of path variables
  • Using singular noun without ID
3. Given the REST API endpoint GET /orders/456, what does this request represent?
medium
A. Retrieve the order with ID 456
B. Create a new order with ID 456
C. Delete the order with ID 456
D. Update the order with ID 456

Solution

  1. Step 1: Understand HTTP GET method

    GET is used to retrieve or read data from the server without modifying it.
  2. Step 2: Interpret the endpoint path

    The path '/orders/456' points to a single order resource with ID 456.
  3. Final Answer:

    Retrieve the order with ID 456 -> Option A
  4. Quick Check:

    GET /orders/456 = Retrieve order 456 [OK]
Hint: GET + /resource/{id} means fetch that resource [OK]
Common Mistakes:
  • Confusing GET with POST or DELETE actions
  • Assuming the request modifies data
  • Misreading the resource ID
4. Identify the error in this REST API endpoint for deleting a user: DELETE /deleteUser/789
medium
A. Missing query parameter for user ID
B. Using a verb 'deleteUser' in the resource path
C. Using DELETE method instead of GET
D. Using plural noun instead of singular

Solution

  1. Step 1: Check resource naming conventions

    Resource paths should be nouns, not verbs or actions.
  2. Step 2: Analyze the given endpoint

    The path '/deleteUser/789' incorrectly includes the verb 'deleteUser' instead of just '/users/789'.
  3. Final Answer:

    Using a verb 'deleteUser' in the resource path -> Option B
  4. Quick Check:

    Resource path must be noun, not verb [OK]
Hint: Avoid verbs in paths; use HTTP methods for actions [OK]
Common Mistakes:
  • Including action verbs in URL paths
  • Confusing HTTP method with URL naming
  • Using query parameters unnecessarily
5. You want to design a REST API for managing comments on blog posts. Which of the following is the best noun-based resource path to list all comments for a post with ID 42?
hard
A. /posts/42/comments
B. /getCommentsForPost/42
C. /comments?postId=42
D. /postComments/42

Solution

  1. Step 1: Understand nested resource naming

    Comments belong to posts, so nesting comments under posts is clear and RESTful.
  2. Step 2: Evaluate the options

    Option '/posts/42/comments' uses plural nouns and shows the relationship clearly without verbs or query parameters.
  3. Final Answer:

    /posts/42/comments -> Option A
  4. Quick Check:

    Nested plural nouns show resource hierarchy [OK]
Hint: Use nested plural nouns for related resources [OK]
Common Mistakes:
  • Using verbs in paths like 'getCommentsForPost'
  • Using query parameters instead of nested paths
  • Using singular nouns inconsistently
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