API Design Interview Questions and Answers
REST resources and HTTP semantics, status codes, errors, pagination and filtering, versioning, idempotency, caching, auth, OpenAPI, GraphQL, gRPC, webhooks and real-time APIs.
225 questions for API Design interviews with answers and explanations - Junior, Middle and Senior levels. Sample questions, online quizzes and coding tasks.
- REST
- HTTP
- OpenAPI
- GraphQL
- Webhooks
Questions by level
Junior
Core concepts and syntax · 50 questions
Middle
Practice, nuances and optimization · 50 questions
Senior
Architecture, internals, edge cases · 50 questions
Sample questions
A few questions from each level with the correct answer and an explanation.
API Design · Junior
- What is a REST API, in practical terms?
Correct answer: An HTTP API organized around resources identified by URLs, manipulated with standard methods like GET, POST, PUT, PATCH and DELETE
REST is an architectural style described by Roy Fielding. Most 'REST APIs' follow its main ideas: resources, uniform interface, statelessness and cacheability.
- Which URL design follows common REST conventions?
Correct answer:
GET /users/42/ordersURLs name resources (nouns, usually plural); the HTTP method says what to do. Verbs in paths are an RPC style.
- What does 'stateless' mean for a REST API?
Correct answer: Each request carries everything the server needs (e.g. auth token); the server doesn't rely on session state from previous requests
Statelessness makes horizontal scaling easy: any instance can handle any request.
- Which HTTP method should create a new resource in a collection, like a new order?
Correct answer:
POST /ordersThe server assigns the ID and usually responds with
201 Createdand aLocationheader pointing to the new resource.
API Design · Middle
- How would you model 'cancel an order' in a REST API?
Correct answer: As a state change (
PATCH /orders/42with{status: "cancelled"}) or a custom action (POST /orders/42:cancelor/orders/42/cancellation), documented consistentlyCancelling usually keeps the order for history and may have business rules. A dedicated action makes those rules explicit; GET must never change state.
- When should a relationship be its own resource, like
/users/42/memberships?Correct answer: When it has its own data or lifecycle (role, joined date, approval), not just a link between two items
Treating a membership as a resource gives you natural create, update and delete operations on it.
- What does JSON Patch (RFC 6902) look like?
Correct answer: A list of operations like
{ "op": "replace", "path": "/email", "value": "a@b.c" }Operations include add, remove, replace, move, copy and test. It's precise for arrays but more complex for clients.
- How can a REST API let clients load related resources in one request?
Correct answer: With an expansion parameter like
?include=author,comments(JSON:API) or?expand=customerExpansion avoids chatty clients while keeping default responses small. Limit how deep and how many relations can be included.
API Design · Senior
- How do you choose between REST, GraphQL and gRPC for a new system?
Correct answer: By consumers and constraints: REST for public, cacheable resource APIs; GraphQL for varied UI data needs; gRPC for internal low-latency service calls with typed contracts
Many systems mix them: gRPC between services, a GraphQL or REST BFF for clients, and REST for public partners.
- What is an 'API as a product' mindset?
Correct answer: Treating the API's consumers as customers: stable contracts, good docs, onboarding, versioning policy, support and usage metrics
Internal APIs benefit too: other teams are customers whose productivity depends on your design.
- Why establish API governance (style guide, reviews, linting) in an organization with many teams?
Correct answer: So APIs feel like one platform: consistent naming, errors, pagination and auth, which lowers integration cost for every consumer
Automate what you can (Spectral rules, breaking-change checks) and keep human review for modeling decisions.
- How do Hyrum's Law and 'be conservative in what you send' interact in API evolution?
Correct answer: Every observable behavior gets depended on, so expose as little as needed, document guarantees explicitly and avoid accidental contracts like field order
Even error message text, default sort orders or response timing can become something clients rely on.
Combined quizzes with this topic
Questions from several topics at once - just like an interview for a specific role.
Coding tasks
Write your solution right in the browser, and tests check it instantly. JavaScript interview classics (debounce, deepClone, Promise.all, an LRU cache) and React components and hooks like a todo list, tabs, useDebounce and useInterval.
Open tasks →