Client to make service call for meta

Hi - I am having a service which returns collection of users. However at times i need to return only count of collection, rather than the actual resources. How would i achieve the same using json api.

I know count is part of META while returning collection.
In this case

  1. How the service should be designed to return only META
  2. How the client should request such services only for META

Appreciate your suggestions

If your service supports pagination query params you can send your request with a limit of 0. This would return no actual resources but the meta block should still contain any additional information about the collection such as the total.

For example:

GET /users?page[limit]=0

Might return:

{ "data": [], "meta": { "count": 100 } }

You might want to specify an include parameter so that your collection only has id & type attributes. This would lighten the response and allow you to use a generic endpoint. In your case, you’ll ignore the users collection and only concentrate on the meta data to get the count value.

I’ve done as @josh suggested. There’s nothing wrong with requesting a limit of zero. If you do not allow that, you can limit to 1 item; using include would reduce the data being returned.