Home > Software design >  RESTful API Standard when wanting all data under RESOURCE
RESTful API Standard when wanting all data under RESOURCE

Time:10-10

All RESTful examples seem to only consider the RESOURCE at that level, e.g.

HTTP GET http://www.appdomain.com/users
HTTP GET http://www.appdomain.com/users?size=20&page=5
HTTP GET http://www.appdomain.com/users/123
HTTP GET http://www.appdomain.com/users/123/address

What if I want users and address to be returned at the same time? E.g. users, address and anything underneath? What is the RESOURCE naming standard then? Or is there another approach? E.g.

HTTP GET http://www.appdomain.com/usersALLdata/123

Is this correct? Or should it be? HTTP GET http://www.appdomain.com/users/123/address/xyz... Seem an issue if address were to have xyz and abc tables both as children. Cannot find any guidance on this.

My conclusion is you must add parameters. E.g. like so https://api.github.com/users/zellwk/repos?sort=pushed

meaning we would use:

HTTP GET http://www.appdomain.com/users/123?ALL=true 

Looking for confirmation.

CodePudding user response:

There is no standard way to do this unless you decide to follow a standard API building solution. But even those just recommend certain URIs. http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html

Normally I would not care much, just respond with a verbose JSON unless I really want to support some sort of advanced search.

  • Related