REST stands for Representational State Transfer. It is an architectural style for designing networked applications.
Click to reveal answer
beginner
Why should REST APIs use nouns in their endpoint URLs instead of verbs?
REST APIs use nouns to represent resources because HTTP methods (GET, POST, PUT, DELETE) define the action. This keeps URLs simple and consistent.
Click to reveal answer
intermediate
What HTTP method is typically used to update an existing resource in REST API?
The PUT method is typically used to update an existing resource completely, while PATCH is used for partial updates.
Click to reveal answer
beginner
What is the purpose of status codes in REST API responses?
Status codes tell the client if the request was successful or if there was an error, and what type of error occurred. For example, 200 means success, 404 means resource not found.
Click to reveal answer
intermediate
How can REST APIs handle versioning to maintain backward compatibility?
Versioning can be handled by including the version number in the URL path (e.g., /v1/resource) or in request headers. This allows clients to use different API versions without breaking.
Click to reveal answer
Which HTTP method is used to retrieve data from a REST API?
APOST
BPUT
CGET
DDELETE
✗ Incorrect
GET is used to retrieve data without changing the resource.
In REST API design, what should the URL /users/123 represent?
AA list of all users
BA specific user resource with ID 123
CAn action to update user 123
DA login endpoint
✗ Incorrect
URLs represent resources, so /users/123 points to the user with ID 123.
What status code indicates that a resource was not found?
A404
B201
C200
D500
✗ Incorrect
404 means the requested resource does not exist.
Which HTTP method is best for creating a new resource?
ADELETE
BGET
CPUT
DPOST
✗ Incorrect
POST is used to create new resources.
How can you version a REST API to avoid breaking existing clients?
AInclude version number in URL or headers
BAvoid using HTTP status codes
CUse only POST method
DChange URLs randomly
✗ Incorrect
Including version info in URLs or headers helps maintain backward compatibility.
Explain the key principles of REST API design and why they matter.
Think about how REST APIs organize resources and communicate actions.
You got /5 concepts.
Describe how you would design a REST API endpoint for managing books in a library system.
Focus on resource naming and HTTP methods.
You got /6 concepts.
Practice
(1/5)
1. Which HTTP method is typically used to retrieve data from a REST API without modifying it?
easy
A. DELETE
B. POST
C. GET
D. PUT
Solution
Step 1: Understand HTTP methods in REST
GET is used to request data without changing the server state.
Step 2: Match method to action
POST creates or modifies data, PUT updates, DELETE removes data.
Final Answer:
GET -> Option C
Quick Check:
Retrieve data = GET [OK]
Hint: GET is for reading data only, no changes [OK]
Common Mistakes:
Confusing POST with GET
Using PUT for data retrieval
Thinking DELETE retrieves data
2. Which of the following is the correct URL format to access a specific user with ID 123 in a REST API?
easy
A. /users/123
B. /users/getUser?id=123
C. /getUser/123
D. /users?id=123
Solution
Step 1: Identify RESTful URL design
REST URLs use resource names and IDs as path segments, not actions or query for specific resource.
Step 2: Compare options
/users/123 correctly points to user resource with ID 123; others use verbs or query parameters incorrectly.
Final Answer:
/users/123 -> Option A
Quick Check:
Resource ID in path = /users/123 [OK]
Hint: Use resource path + ID, avoid verbs in URL [OK]
Common Mistakes:
Using verbs like getUser in URL
Using query params for resource ID
Mixing action names with resource paths
3. Given the following REST API call: DELETE /orders/456, what is the expected outcome?
medium
A. It deletes order 456 from the system
B. It updates order 456's status
C. It retrieves order 456's details
D. It creates a new order with ID 456
Solution
Step 1: Understand HTTP DELETE method
DELETE is used to remove a resource identified by the URL.
Step 2: Analyze the URL and method
/orders/456 points to order with ID 456; DELETE removes it.
Final Answer:
It deletes order 456 from the system -> Option A
Quick Check:
DELETE + resource ID = delete resource [OK]
Hint: DELETE method removes resource at given URL [OK]
Common Mistakes:
Thinking DELETE retrieves data
Confusing DELETE with POST
Assuming DELETE creates or updates
4. A developer designed a REST API endpoint as POST /users/123/updateEmail to update a user's email. What is the main issue with this design?
medium
A. Using POST instead of GET for update
B. Including action 'updateEmail' in the URL violates REST principles
C. Missing user ID in the URL
D. Using query parameters instead of path variables
Solution
Step 1: Review REST URL design principles
REST APIs should use resource paths, not actions in URLs.
Step 2: Identify the problem in the URL
Including 'updateEmail' is an action, which breaks REST design; updates should use PUT or PATCH on /users/123.
Final Answer:
Including action 'updateEmail' in the URL violates REST principles -> Option B
Quick Check:
URLs represent resources, not actions [OK]
Hint: Avoid verbs in URLs; use HTTP methods for actions [OK]
Common Mistakes:
Using verbs in URL paths
Confusing POST with GET for updates
Omitting resource IDs
5. You need to design a REST API for a system managing books and their authors. Which design best follows REST principles for retrieving all books by a specific author with ID 789?
hard
A. /books/authors/789
B. /books?author=789
C. /getBooksByAuthor/789
D. /authors/789/books
Solution
Step 1: Understand resource hierarchy in REST
Authors and books are resources; books by an author are a sub-resource of author.
Step 2: Evaluate URL options
/authors/789/books clearly shows books belonging to author 789, following REST resource nesting.
Step 3: Consider query vs path
While query parameters can filter, nested resource path is more RESTful for related resources.
Final Answer:
/authors/789/books -> Option D
Quick Check:
Nested resource path shows relationship [OK]
Hint: Use nested paths for related resources [OK]
Common Mistakes:
Using verbs in URL
Overusing query parameters
Ignoring resource relationships
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.