Lets say I have a resource representing a list of items for a user. Something like this:

    id: 1,
    name: "list item 1",
    hidden: false,
    id: 2,
    name: "list item 2",
    hidden: true,

I can hide or show individual items by issuing a PUT or a PATCH request.

I can filter to just the visible items by adding ?hidden=false

But how do I handle show all, or show only this one?

My item list might be 1000 items. I might not want to pull everything by default. Even if I do, it might be paged. I might not have, or want to have knowledge of the entire list in order operate on it.

I guess I could "show all" by PATCHing the collection as it's effectively "update all", but "show only this one" is "update all to hidden, then update this to not hidden"

I think I may have answered my own question during the typing of it (thanks rubber duck), but I'm curious as to people's answers how to handle these types of updates.

  • First, I think a more appropriate name would be items instead of item-list. Dealing with show only this one, does /users/:userId/items/:itemId not work for you? A request to a single item then obviously does not need pagination, while request to /users/:userId/items could. – Andy Jul 28 '17 at 12:40
  • I should point out that the naming is an example and not reflective of my actual resource. It seems like you're suggesting two calls, one to the collection to hide them all, and one to the individual item to make sure it is shown. – JamesT Jul 28 '17 at 13:37
  • What's wrong with /users/x/item-list/all and /users/x/item-list/1 ? – Laiv Jul 28 '17 at 18:10
  • What's right with it? Elaborate. How do I do "show only this one", Vs "show this one" using the above. – JamesT Jul 30 '17 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.