Api Design easy
You need to release a breaking change to your API. How should you version it?
- A Use a URL path prefix (e.g., /v1/users) to clearly distinguish this from previous versions.
- B Add a numeric suffix to the filename (e.g., users_v2.json).
- C Rely on the client to parse the response and detect schema changes automatically.
- D Include a mandatory 'version' field in the JSON body of every POST request.
Answer: A. Use a URL path prefix (e.g., /v1/users) to clearly distinguish this from previous versions.
There are multiple strategies for API versioning, each with trade-offs. URL path versioning (like `/v1/users`) is the most explicit and easiest for developers to see and debug. Header-based versioning is cleaner (keeps URLs 'pure') but harder to test in a browser. Query parameters are simple but can interfere with caching. Choose the strategy that best fits your ecosystem, but be consistent.
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?