Reputation: 2259
I have resource collection users and each user can have a filter, so another resource collection is filters.
So, to retrieve filters we have this url
/users/:id/filters
How should be url to retrieve a filter by id?
Upvotes: 1
Views: 1495
Reputation: 2259
/companies/{id}
and /employees/{id}
). The URLs are shorter, easier to remember and not many parameters are required.
https://stackoverflow.com/a/19285843/7527624
https://stackoverflow.com/a/32820784/7527624
Upvotes: 1
Reputation: 1204
Are the filters first-class entities or owned by a user? For example, can a filter belong to two users or put in another way, is a filter created then assigned to one or more individuals?
If the filters are properties of the users (one filter to one user, one user to one or more filters) /users/:id/filters/:id makes a lot of sense. If the filters are themselves distinct objects that are related to users (one or more users per filter) then either API (perhaps even both) may make sense depending on how the user is expected to consume the API. If they only care about filters, /filter/:id makes sense, if they only care about users' filters /users/:id/filters/:id is appropriate, or if their needs vary between the two, having both is a sensible solution.
Upvotes: 2
Reputation: 644
/users/:id/filters/:id makes more sense, as the query is to retrieve a specific filter corresponding to a specific user.
Upvotes: 0