參考答案
What the interviewer wants: Systems thinking, not just knowledge of HTTP verbs. Interviewers want to see that you consider performance, reliability, versioning, documentation, and evolution from the beginning.
How to structure your answer: Walk through your design process step by step, covering resource modelling, consistency, authentication, error handling, versioning, and performance considerations. Use a concrete example if possible.
Sample Answer
"When designing a scalable API, I start by understanding the domain thoroughly before writing any code. I model resources around business entities, keep endpoints predictable following REST conventions, and define clear request and response schemas upfront. For authentication, I use JWT with short expiry combined with refresh token rotation, or OAuth2 where third-party access is involved. I design error responses consistently so clients can handle failures predictably â every error returns a machine-readable code alongside a human-readable message. For versioning, I use URL path versioning like /v1/ at the beginning and plan migration paths before deprecating old versions. On the performance side, I design for pagination from day one, identify endpoints that will be read-heavy and add caching headers or a Redis cache layer early, and ensure database queries use appropriate indexes. I also write OpenAPI documentation alongside the implementation so the contract is always accurate. At my previous company, this discipline meant we could onboard third-party partners to our payment API within hours rather than days."