In a REST api what is the most efficient way to handle user specific data for items?
For example, let's say there are item
resources that can be favourited. A list of items can be accessed by:
https://myservice.com/api/items (Full list)
https://myservice.com/api/items/{id} (Single item)
Which returns
{
{ 'name': 'name 1' },
{ 'name': 'name 2' },
}
Each item can be favourited by a user (https://myservice.com/api/user/{id}
) and a list of these favourites would be available at:
https://myservice.com/api/user/{id}/favorites
This whole setup is stateless; however, there may be hundreds of favourites and retrieving a full list may not be needed.
Q: Whilst maintaining a stateless system what is the best way to combine getting an item with the user specific data?
i.e. Is it sensible, or plausible, to get a user-specific list of items:
https://myservice.com/api/items?user={id}
{
{ 'name': 'name 1', 'isFavourite':true },
{ 'name': 'name 2', 'isFavourite':false },
}