I am building an API with Loopback.io, and I have been thinking about how should I design some of the endpoints. To get in context:
a Person hasMany Groups,
a Group hasMany People (and one of them is the admin),
a Member is the "Through" model for Person and Group,
a Group hasMany Sessions.
Now I have (A):
- /People
- /People/{id}/Groups
- /Groups
- /Groups/{id}/Sessions
which is the API generated by Loopback. 2 and 3 are "repeated" endpoints, however 2 creates a Member instance and 3 does not.
Option B:
- /People
- /People/{id}/Groups
- /People/{id}/Groups/{groupId}/Sessions
Option C:
- /People
- /Groups
- /Groups/{id}/Sessions
I would like to know which is the best approach and if the A solution would be good enough. Thank you very much.