jsonjson-apijsonapi-resources

JSON API filter included resources


The question is about JSON API specification and how properly do a request (I'm using ruby on rails and the json api resources gem but that's a general question anyway, I know how to implement it, I just want to follow the rules of JSON API at: http://jsonapi.org/format/)

Situation 1:

Situation 2:

What would be correct way of designing request for all shelves with included unread books?

Can't figure this one out

www.library.com/shelves?include=books&filter[books.unread]=true ?

www.library.com/shelves?include=unread_books ? <- would have to specify another resource, books that are unread

www.library.com/shelves?filter[books.unread]=true ?

What's the most correct way of doing this?

EDIT

After speaking with my tech lead and a few other programmers, the first options is favoured the most in such cases


Solution

  • I would bet on the first one:

    www.library.com/shelves?include=books&filter[books.unread]=true