RESTFul Flat hierarchy versus dynamic hierarchy for search resource

We are creating a REST API, and currently we have two approaches for defining resources.

We basically have Patients, Studiesand Images, where a Patienthas n Studiesand a Studyhas n Images.

Hierarchical approach

/webapi/patients/0/studies/12/images 

The hierarchy is visible in the URI

To search all the images we need a search resource

 /webapi/search?q=imageName:mountain

Flat approach

/webapi/patients/0
/webapi/studies/12
/webapi/images/

The hierarchy is performed using an attribute (for example, it study 12has patientId0).

To search for all images, we can search the resource itself:

 /webapi/images?q=imageName:mountain

Is there a best practice approach or has anyone come across a similar scenario? Whether the search resource is REST or it is bad that the relation from the image is not visible in a flat approach.

We also need to think about moving and modifying.

+4
2

URI RESTful. . RESTful, , URI .

/wepapi/patients/0/studies/12/images? 12.

? .

? :

  • wepapi ( ) . RESTful URI "" (. HTTP Accept ).
  • patients/0 . , , URI, ... . URI "".

/search?q=imageName:mountain? , "".

? , . , ? :

  • search , RESTful. , URI "" " " (, ), , "".

, : /studies/12/images /images/?studies=12 , "" /studies/12 /images/?name=mountain - . , . REST, URI (, "" ). URI (JSON, XML, HTML...), .

+4

, URI REST. URI, . , , , URI. REST , , URI, REST , URI, ( URI ).

HATEOAS , . . . IANA- ( , RDF), schema.org .. ( RDF). , URI.

URI . - :

  • : , URI .
  • , URI , . URI, - . , POST /users/123?update=true&partial=true body update. , HTTP- , : PATCH /users/123 body . HTTP, GET, POST, PUT, DELETE, PATCH, etc..., () .

-, , . , , .

/wepapi/patients/0/studies/12/images - , 12- 0- . /images?patient=0&study=12, , /images?study=0_12. Btw. REST. , URI.

REST - , . ppl , . , - , . , , Hydra, RESTdesc .. , REST . , , 15 ...

+4

All Articles