Building REST web services with nested collections + collections inside entries

137 Views Asked by At

I would like to build a REST webservice that would provide :

  1. nested collections,
  2. collections inside entries.

Nesting collections would be used to refine a concept from general to particular, for example :

/vehicles/road_vehicles/cars/AB-123-CD

The idea is to limit the number of concepts appearing at the root of the webservice.

Collections inside entries would be used to access parts of the entries, for example :

/cars/AB-123-CD/engine/spark_plugs/1

could be a good URI for the first spark plug of the car whose id is "AB-123-CD". A nested collection makes sense whenever the deletion of the "container" means the deletion of all its parts.

DELETE /cars/AB-123-CD

would obviously delete :

/cars/AB-123-CD/engine/spark_plugs/1

and all other parts of the car (think of the car as being sent to scrap by the DELETE).

Question : while this kind of "clean URIs" are quite a common need, are there any software to simplify the building of such a webservice?

It seems that the Atom Publication Protocol (AtomPub) could have been a good candidate, since their vision of webservices if very close to what I want, but it doesn't seem to support nested collections.

1

There are 1 best solutions below

0
On

The article The future of API design: The orchestration layer indicates Query-based APIs are putting the power in the hands of the requesting developer, although that power is limited. Using AtomPub along with query parameters is available to you in AtomPub build tools. I found some examples searching for "APIs Query-based" but could not find an actual definition.

https://developers.google.com/google-apps/contacts/v3/#retrieving_contacts_using_query_parameters
http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Query_Related_Records_Map_Service_Dynamic_Layer/02r3000000nt000000/

Author goes on to say that Experienced-based APIs have device-specific wrappers but they are designed, implemented and owned by the device teams. Maybe the way to approach your issue is to create to different AtomPub end-points which present different views of the information?