You'll find opinionated answers on this because it's subjective to the use case. There is no right answer here. Ideally, you design the API to suit your use case the best.
event/:event-id/members
vs/members
Questions I'd ask myself: Will the "member" resource stand alone? Fox exFor example:
Will I need to fetch members across events (for say performing analytics) ? I can always GET
/members
and filter onevent-id
as a query param.Do I want to add multiple endpoints to support cleaner usage, like POST
event/:id/members
and GET/members/:id
?
- I've found that nesting in the manner you mention (3 level) does not scale well for the same reason above - today you nest members under mini-event. Tomorrow, if you need to access members across events (analytics as an example), you'd have to duplicate an endpoint. If it was a root level, again, simply add parameters.
In your case, if a member can belong to both an event and mini-event, you're already having multiple endpoints. Avoid that, it makes documentation harder.
Avoid something like PATCH event/:event-id/mini-event/:mini-event-id/members/:member-id
. PATCH members/:id
is easier to work with
In conclusion, here is what you can do. Use GET for /members/
and /mini-events/
with query params. POST, PUT, PATCH and DELETE for /events/:event-id/members/:member-id
and /events/: event-id/mini-events/:mini-event-id
.
Some relevant reading https://martinfowler.com/articles/richardsonMaturityModel.html