All jobs / Backend developer / API Development
Backend developer interview question · 0–1 years
The interviewer asks: “When do you nest URLs like /orders/12/items?” Strongest answer?
The strongest answer
When items are a real sub-resource of that order. If the child is first-class, a flat /items?orderId=12 is clearer than a deep tree.
Why it works
Exactly. Nesting expresses ownership. Deep trees that exist only to pass filters are harder to cache, authorise and document.
What a good answer covers
- Nest real children, not every filter.
- Flat + query is fine for first-class resources.
- Don't build five-level trees by habit.
- Paths are nouns; GET must not destroy.
Answers that fall short
- Close, but not the strongest: Always nest under the user: /users/me/orders/12/items/3/tax.
A five-level path is a maze. Authz and caching get the user from the token, not from /users/me in every URL. - Weak: Never nest — nesting isn't REST.
Nesting is normal REST. The mistake is nesting everything, not nesting at all. - Red flag: GET /orders/deleteAll as a nested resource so it's “under orders.”
A verb in the path is still an RPC. DELETE on a collection, or a POST to a well-named action, — not GET deleteAll.
Who gets asked this
More API Development questions
- In a GraphQL API, what is the schema and what is a resolver?
- The interviewer asks: “Do you return the database entity as JSON?” Strongest answer?
- The interviewer asks: “A handler throws. What does the client see?” Strongest answer?
- The interviewer asks: “How do you paginate a list endpoint?” Strongest answer?
- The interviewer asks: “Where do you validate input?” Strongest answer?
- The interviewer asks: “PUT versus PATCH?” Strongest answer?
- The interviewer asks: “How should API errors look to clients?” Strongest answer?
- The interviewer asks: “How do you version a public JSON API?” Strongest answer?