API Design Junior interview questions and answers
75 questions for a API Design (Junior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.What is a REST API, in practical terms?
- 2.Which URL design follows common REST conventions?
- 3.What does 'stateless' mean for a REST API?
- 4.Which HTTP method should create a new resource in a collection, like a new order?
- 5.What's the difference between
PUTandPATCH? - 6.Which HTTP methods are 'safe'?
- 7.Which methods are idempotent by HTTP semantics?
- 8.What should
DELETE /orders/42return if the order was deleted and there's nothing to send back? - 9.What does the
Locationheader in a201 Createdresponse contain? - 10.Why should resource names in URLs usually be plural nouns, like
/users? - 11.What does
400 Bad Requestmean? - 12.What's the difference between
401 Unauthorizedand403 Forbidden? - 13.Which status code fits 'email is already registered' when creating a user?
- 14.What does
429 Too Many Requeststell the client? - 15.When should an API return
5xxcodes? - 16.What does
503 Service Unavailableusually mean? - 17.Why is returning
200 OKwith{ "error": "not found" }a bad practice? - 18.What does
404 Not Foundmean forGET /orders/999? - 19.What does the
Content-Type: application/jsonrequest header tell the server? - 20.What is the
Acceptheader for? - 21.How should dates and times be represented in a JSON API?
- 22.Why might an API return large numeric IDs as strings in JSON?
- 23.Which field naming style should a JSON API use?
- 24.Where should filtering and sorting options go in a REST request?
- 25.What does a good error response body include?
- 26.What is RFC 9457 (Problem Details)?
- 27.Why should list endpoints be paginated?
- 28.What's the difference between offset and cursor pagination?
- 29.Why should a pagination cursor be opaque to clients?
- 30.How can an API tell clients there are more pages?
- 31.How is a bearer token usually sent to an API?
- 32.Why must APIs be served only over HTTPS?
- 33.What is an API key typically used for?
- 34.What is OAuth 2.0 mainly about?
- 35.What does CORS control?
- 36.Why should an API validate all input even if the official client already does?
- 37.What is OpenAPI?
- 38.What's the benefit of a 'design-first' API approach?
- 39.Why should an API have a style guide?
- 40.What is JSON Schema used for in APIs?
- 41.Which change to an existing API response is usually backward compatible?
- 42.What is a common way to version a REST API?
- 43.Why should clients ignore unknown fields in responses?
- 44.How should an API announce that an endpoint will be removed?
- 45.Which responses can HTTP caches store most safely?
- 46.What is an
ETag? - 47.Why might an API compress responses?
- 48.What is GraphQL?
- 49.What is a webhook?
- 50.What is gRPC typically used for?
- 51.What's the difference between REST and RPC style APIs?
- 52.When do Server-Sent Events fit better than polling?
- 53.What does
HEAD /files/report.pdfreturn? - 54.Why are CORS preflight
OPTIONSrequests sent? - 55.How should nested resources be used in URLs?
- 56.What's a sensible maximum for a list endpoint's
limitparameter? - 57.Why might an API use a request ID header like
X-Request-Id? - 58.Which tool is commonly used to try API requests manually?
- 59.What does 'over-fetching' mean?
- 60.What does 'under-fetching' (or chatty API) mean?
- 61.Should an API expose internal database IDs and table structure directly?
- 62.How should boolean flags be named in API payloads?
- 63.Why are enums in API responses tricky to extend?
- 64.What should a
GETrequest never do? - 65.What does
Retry-After: 120in a response mean? - 66.What is the Richardson Maturity Model?
- 67.What is HATEOAS?
- 68.A user double-clicks 'Pay', and the client sends
POST /paymentstwice. What's the risk and a common fix? - 69.What does
202 Acceptedmean? - 70.How can a client follow a long-running operation started with
202 Accepted? - 71.When is it fine to create a resource with
PUT? - 72.Why do many APIs return
{ "data": [...] }instead of a bare JSON array for lists? - 73.What do headers like
RateLimit-Remaining(orX-RateLimit-Remaining) give clients? - 74.How can a client fetch several users by ID in one request in a REST API?
- 75.What's a common query parameter name for free-text search in a collection?