Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

(create a new composite resource which can represent the entire tree in one go)

This is the problem I face with REST all the time. I have yet to see someone pull this off gracefully. Take the hierarchy Authors/Books/Characters. If I wanted the full list of all Authors, with all Books, with all Characters what are you suggesting I do? Now what if there was another level after that? And after that?

This simple example could work with the use of a 'depth' value which has been suggested. But it doesn't work all the time. Especially when there are forks in the hierarchy and you want to go deeper in one and not the other. Basically I've determined that it seems impossible to have a pure 'model' of your data and an efficient API.



    Take the hierarchy Authors/Books/Characters. If I wanted
    the full list of all Authors, with all Books, with all
    Characters what are you suggesting I do? 
The service could have a /characters resource, which returns a list of all characters, along with the author/book.


Or the top level document looks something like (in JSON):

{ "characters": "<uri>", ... }

Doing a GET on the supplied characters URI gets you a list of characters, each with a mixture of relevant properties and a URI for the character itself so you can interact with it directly.


odata is one solution, I think.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: