RESTful API Design Questions

Designing resource-oriented HTTP APIs following REST constraints: resource modeling, URI structure, correct use of HTTP methods, statelessness, and HATEOAS trade-offs. Covers naming conventions, collection vs. singleton resources, filtering/sorting/pagination, and choosing appropriate status codes. The default paradigm most interview questions in this category probe.

MediumSystem Design
57 practiced

Model the resources and endpoints for an order-management API where an order moves through created, paid, shipped, and cancelled states. Decide how you represent the state transitions themselves: separate action endpoints like POST /orders/{id}/ship and POST /orders/{id}/cancel, or a single PATCH to a status field, and explain the trade-off between the two in terms of URL complexity, discoverability, and what happens when a client tries an invalid transition (for example cancelling an order that already shipped).

EasyTechnical
80 practiced

You are designing the error handling for an API. Pick the single most appropriate HTTP status code, and briefly justify it, for each of: malformed JSON in the request body, a validation error on a business rule, an authentication failure, an authorization failure, a request for a resource that does not exist, a request accepted for asynchronous processing, and a successful resource creation versus a successful update with no content to return. Name one common mistake engineers make on at least two of these.

MediumTechnical
67 practiced

Design the query-parameter contract for a GET /products list endpoint that needs to support multi-field sorting, range filters (for example a price range), boolean and enum flags, and a full-text match on a description field, while staying discoverable and unambiguous to a client reading the URL. What safeguards do you put in place so a client-constructed filter cannot trigger an expensive ad-hoc query that degrades the service for everyone else?

EasyTechnical
75 practiced

Compare URI-path versioning (/v1/resource), header-based versioning (a custom Accept media type), and query-parameter versioning (?version=1) for exposing multiple API versions at the same time. For a public B2B API with many long-lived client integrations, which mechanism would you default to, and how does your choice interact with caching, discoverability, and how much complexity it pushes onto the client?

EasyTechnical
65 practiced

Critique these endpoints and redesign them to follow resource-based REST conventions: GET /getUser?id=123, POST /user/create, GET /v1/get-all-books, and /accounts/123/transactions?start=.... For each, say specifically what is wrong (a verb in the path, inconsistent pluralization, an ambiguous or missing resource identifier) and show your redesigned path and method.

Unlock Full Question Bank

Get access to all 34 RESTful API Design interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.