Normally I expose endpoints in this way:
/api/1/users
/api/1/users/{uid}
/api/1/groups
/api/1/groups/{gid}
/api/1/items
/api/1/items/{iid}
To represent hierarchy I usually go this way:
/api/1/groups/{gid}/users
/api/1/users/{uid}/items
Or to get similar results:
/api/1/users?group_id={gid}
/api/1/items?user_id={uid}
Everything goes well unless you face this:
/api/1/users
/api/1/groups # groups of users
/api/1/items
/api/1/groups # groups of items
Here I could imagine 2 options:
To change the endpoint name:
/api/1/users /api/1/groups /api/1/items /api/1/item_groups
To modify path by adding some prefix or namespace or scope:
/api/1/{users_prefix}/users /api/1/{users_prefix}/groups /api/1/{items_prefix}/items /api/1/{items_prefix}/groups
I prefer prefixes because they make item relations a bit more visible.
On the other hand such conflicts are quite rare and prefixes make path more complex.
Also I have doubts because /api/1/{items_prefix} doesn't represent any resource or collection.
Though /api also doesn't and it is common practice to start path with /api/{version}.
So I can't figure out what is the best approach for resolving name conflicts from perspective of REST principles or best practices?
Thanks in advance.