web services - What is the best URI template for retrieving grouped counts of a particular resource in a REST API? -


i have rest api exposes uri return collection of employees in json. uri of following format:

http://webservice/employees 

i want expose uri returns number of employees grouped by, say, office work in , further information office. example:

items: [{            officeid: 1,            officename: "big office",            switchboardtel: "123456789",            numemployees: 100         },         {            officeid: 2,            officename: "small office",            switchboardtel: "987654321",            numemployees: 30         },         ... // etc.        ] 

what suitable uri this? thinking given returns information offices (along number of employees), perhaps information should retrieved via "offices" resource:

http://webservice/offices 

alternatively, following uri more suitable?

http://webservice/employees?groupby=office 

in opinion, seems wrong response returns information offices, rather employees, along employee count.

say wanted expose uri returned number of employees grouped age... belong "employees" resource, such as:

http://webservice/employees?groupby=age 

...or better suited creating "ages" resource:

http://webservice/ages 

in opinion, "groupby=age" option seems best here...but kind of makes uri formats inconsistent.

basically, want consistent uri format count of employees grouped criteria - , response contain information grouping.

thanks in advance help.

tom


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -