API Design Essentials: Advanced Concepts Quiz Quiz

Assess your expertise on core API design principles including resource modeling, validation, and versioning through challenging scenarios and nuanced questions.

  1. Identifying Resource Modeling Mistakes

    When designing an API for a library system, which of the following URI formats most clearly violates RESTful resource modeling conventions?

    1. /genres?type=fiction
    2. /books/123
    3. /book_s/123
    4. /authors/45/books
    5. /books/123/checkout
  2. Choosing HTTP Methods Appropriately

    If a client wants to update only the title of an existing article, which HTTP method should be used according to proper API design principles?

    1. PATCH
    2. FETCH
    3. GET
    4. SEARCH
    5. RETRIEVE
  3. Designing Input Validation Strategies

    Which validation technique ensures both data format correctness and compliance with business logic before processing API requests?

    1. Syntactic validation
    2. Schema validation
    3. Lexcial validation
    4. Semantic validation
    5. Minimal validation
  4. Versioning Strategy Impacts

    Why should an API avoid embedding the version number in the resource path, for example, /v1/users, in certain circumstances?

    1. It forces clients to use obsolete endpoints
    2. It breaks HTTP caching
    3. It disallows query parameters
    4. It obscures the resource identification
    5. It increases response size
  5. Correct Use of HTTP Status Codes

    When a client sends an API request with valid JSON format but violates a required business rule (e.g., age u003C 18), which HTTP status code should be returned?

    1. 418 I'm a teapot
    2. 301 Moved Permanently
    3. 503 Service Unavailable
    4. 200 OK
    5. 422 Unprocessable Entity
  6. Idempotence in HTTP Methods

    Which HTTP method is inherently idempotent even when used repeatedly on the same resource in an API?

    1. POST
    2. PATCH
    3. PUT
    4. TRACE
    5. CONNECT
  7. Handling Backward Compatibility

    If a breaking change is required in an API's data structure, what is the most reliable way to maintain backward compatibility for existing clients?

    1. Change the data silently
    2. Introduce a new versioned endpoint
    3. Deprecate all old methods immediately
    4. Force all clients to adapt instantly
    5. Modify the response format in-place
  8. Filtering Versus Nested Resources

    In a photo-sharing API, which URI pattern best reflects filtering by user rather than representing a nested resource relationship?

    1. /photos?userId=42
    2. /user/photos/42
    3. /photos/users/42
    4. /photos/42
    5. /users/42/photos
  9. Choosing Resource Identifiers

    Why is using opaque unique identifiers (such as UUIDs) preferred over sequential integers in API endpoints for resource identification?

    1. They ensure alphabetical ordering
    2. They make URLs shorter
    3. They simplify pagination code
    4. They prevent information leakage and are harder to guess
    5. They increase processing speed
  10. Soft vs. Hard Validation Errors

    In a scenario where an API accepts an address field and the city value is unrecognized but still valid, which approach describes proper API validation response?

    1. Silently correct the value
    2. Immediately deprecate the endpoint
    3. Completely ignore the city field
    4. Reject the request with a 500 status
    5. Return a warning while accepting the request