API Design · Junior · Question 55 of 75
How should nested resources be used in URLs?
- ✓Correct answer: For clear ownership one level deep, e.g.
/users/42/orders; avoid deep chains like/a/1/b/2/c/3/d - 2Always nest as deep as the data model goes
- 3Never use nesting
Explanation
Deep nesting makes URLs long and forces clients to know the whole hierarchy. Items with their own IDs can also be accessed at the top level.