Api Design easy
A REST purist suggests adding 'links' to your API responses, e.g., { data: {...}, _links: { self: '/orders/123', cancel: '/orders/123/cancel' } }. What is this principle called?
- A SOAP (Simple Object Access Protocol)
- B HATEOAS (Hypermedia as the Engine of Application State)
- C WSDL (Web Services Description Language)
- D HSTS (HTTP Strict Transport Security)
Answer: B. HATEOAS (Hypermedia as the Engine of Application State)
**HATEOAS** (Hypermedia as the Engine of Application State) is a constraint of the REST application architecture. It suggests that a client should interact with a network application entirely through hypermedia provided dynamically by application servers. By including links (e.g., `_links` or `links`) in the response, the API guides the client on available next actions, decoupling the client from hardcoded URLs.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- You're designing a REST API for a blog. Which endpoint best represents 'get all comments for post 123'?
- A client wants to update only the 'status' field of an order, leaving other fields unchanged. Which HTTP method is most appropriate?
- A client calls POST /users with valid data, and the user is created. What status code should the server return?
- A client retries a failed 'POST /payments' request due to network timeout. The server receives the request twice. Without idempotency handling, what can happen?
- An API returns 10,000 products. Returning all in one response is impractical. Which pagination approach is simple and stateless?
- Your API serves both mobile apps and third-party integrations. Which authentication method is most appropriate?