This quiz explores common REST API anti-patterns, helping you recognize poor design choices and understand best practices for creating efficient, scalable web services. Sharpen your skills in RESTful architecture by learning which patterns to avoid for optimal API performance and usability.
Which anti-pattern is demonstrated when an API endpoint like /data processes completely different request payloads for several unrelated operations?
Explanation: Overloaded endpoints handle multiple unrelated responsibilities under a single URI, which makes APIs hard to use and maintain. Incorrect status code refers to sending the wrong HTTP response codes. Verbose resource naming involves unnecessarily long or complex URIs. Resource nesting is about deeply nesting resources, not overloading a single endpoint.
If an API uses the POST verb to retrieve data, such as '/users/filter', which REST anti-pattern is being exhibited?
Explanation: Using POST to retrieve data violates REST principles, since GET is intended for fetching resources without side effects. Ignoring content negotiation relates to response formats. Under-specified URLs refers to endpoints lacking clarity. Incorrect header management is unrelated to HTTP verb selection.
What is the primary issue with excessively deep resource nesting in REST APIs, such as '/users/1/orders/5/items/2/reviews/4'?
Explanation: Resource nesting becomes an anti-pattern when it creates overly complex, deeply embedded URL structures, making APIs less flexible and harder to maintain. Ambiguous endpoints are those lacking clarity in purpose. Data loss is not directly tied to nesting depth. Unsecured endpoints are a security issue, not a structural one.
When an API always returns a 200 OK status for errors as well as successes, what anti-pattern is being demonstrated?
Explanation: Returning 200 OK for both successes and failures confuses clients and prevents clear error handling, a classic inconsistent status codes anti-pattern. Superfluous response data refers to sending unnecessary information. Bulk fetching means retrieving large datasets inefficiently. Improper versioning deals with version management, not status codes.
Consider an API endpoint like '/getAllTheUserAccountsListNow'; what anti-pattern does this reflect?
Explanation: Overly long and descriptive URIs violate REST principles, which encourage simple, pluralized nouns like '/users' for clarity and usability. Rate limiting concerns request throttling, not naming. Circular references happen when objects reference each other indefinitely. Mutable resource identifiers relate to changing IDs, not name verbosity.