RESTful route for a list of members that are not part of a collection

I am trying to figure out what is the best way to show a list of members (users) that are not a collection (group).

/users 

      

is my route to list all users in an account

/group/:id/members 

      

is my route to list all users in a group

/users?not_in_group=:id 

      

is my current option for displaying a list of NOT users in a group. Is there another RESTFul way to display this?

/group/:id/non_members 

      

seems odd ...

+2


source to share


3 answers


You can use either query parameters or paths to get the desired view. But I would go for Pete's advice and make sure your API is hypertext-driven . This does not mean that communication between client and server should be prevented by REST.

The best answer to your question may depend on your application. For example, if your system is small enough, it may be sufficient to support only a view consisting of a list of users and their respective groups (resource found at / users). Then let the client figure out what they want to do with the information. If your system has many groups and many users, each of which belongs to only a few groups, your view of available_users for any group is likely to be slightly smaller than the entire list of users.



Creative design of media types can go a long way towards solving such problems.

+2


source


Talk to my partner. He offered:

/group/:id/available_members

      



Seems much more positive.

0


source


The core precept of REST is "hypertext as the engine of application state". The form of the URI does not matter, what matters is that it is navigable from the view returned at the entry point of the application.

0


source







All Articles