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.
Design the REST endpoints for a Book resource that also has nested Reviews belonging to it: list, get one, create, update, and delete a book, plus list and add reviews for a book. For each endpoint give the HTTP method, the canonical path, the expected request body where relevant, and the success status code. How do you keep the response shape for the list endpoint from triggering an N+1 query when reviews are included, and how does pagination interact with the nested collection?
For a public partner API, an internal high-throughput service mesh, and a mobile client on unreliable networks, would you reach for REST, GraphQL, or gRPC? Compare the three on caching, client flexibility, network overhead, versioning, and developer ergonomics, and justify a different choice (or the same one) for each of the three scenarios.
What conventions do you use for naming REST resources and endpoints: plural versus singular nouns, when to nest a resource under its parent (for example /users/{userId}/orders) versus keep it top-level, how to represent an action that is not plain CRUD without falling back to an RPC-style verb in the URL, and how you keep the number of endpoints from exploding as relationships between resources grow.
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.
REST requires the server to hold no client session state between requests. Explain what statelessness does and does not forbid (a server may still hold data about the resource itself, just not about a specific client's conversation), and describe two concrete techniques for handling per-user needs like login sessions without server-side session state. What does statelessness buy you operationally when traffic spikes and an instance needs to be replaced, and what do you give up?
Unlock Full Question Bank
Get access to all 33 RESTful API Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.