-2

Please help me to understand how to expose service in REST. Is it depends on RESOURCE or depends on the size of data ?

Example: Let we take 2 resources (STUDENT & DEPARTMENT). Now I have an requirement of exposing "Total number of Students" and "Total number of Departments".

How should I expose a service now ?

  1. Is it like exposing 2 different resource(api/student/total & api/department/total) ?
  2. Or can it be do like this(api/total/student,department) since the response data will be very minimal ?

Should we consider the response size when deciding about Resources ?

Pavan
  • 337
  • 1
  • 4
  • 10
  • http://stackoverflow.com/questions/3715981/whats-the-best-restful-method-to-return-total-number-of-items-in-an-object – Stefan Jan 23 '15 at 12:23

1 Answers1

0

It depends.

If you want a very clean interface, that sticks as strict as possible to the REST-rules, than use solution 1. I would recommend this if you expose your API to the internet for a broad audience.

If you want to optimize performance use solution 2. This would especially make sense if you know all the appications that use your API and sticking to official rules is less important.

slartidan
  • 20,403
  • 15
  • 83
  • 131