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.
Show what a JSON response for an order resource would look like if it included hypermedia links for the actions currently available on it (for example pay, cancel, and view items). Explain what HATEOAS is supposed to buy a client that the links alone would not otherwise know, and give the concrete reason most public REST APIs today skip full hypermedia even though the specification recommends it.
Internal service failures need to become HTTP status codes and client-facing error codes without leaking internal details (stack traces, internal service names, database error text). Design the translation layer that does this mapping, and describe how you would instrument it so an SRE can still see the real internal error for debugging even though the client only sees the sanitized version.
For each of GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS, state whether it is safe, whether it is idempotent, and whether it is cacheable, then give a short example endpoint where using the wrong method caused a real bug (for instance, a client retry duplicating a purchase, or a caching layer serving a stale response for a method it should not have cached).
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).
Compare offset-based pagination, numbered pages, and cursor-based (keyset) pagination for a REST list endpoint. For each, note what happens to correctness and performance when rows are being inserted or deleted while a client is paging through results, and when you would still choose offset pagination despite its downsides (for example an admin UI that needs to jump to page 40).
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.