Reputation: 5367
I'm building a RESTful webservice:
GET /clients
, I'm getting the list of all known clients.GET /clients/1
, I'm getting the client object for the clientId
1.Everything as it should be.
Those clients have a property called authorized
. On my web UI to manage those, I have separated tables for authorized and unauthorized clients. Of course, I do not want to load all the clients from the server just to display the unauthorized ones.
The question is, how could I filter the client over a RESTful URL? As I want to do a proper RESTful API, query parameters are not an option.
I already thought about additionally doing GET /unauthorizedClients
and GET /authorizedClients
but this seems not right, as I still would use DELETE
/clients/%clientId%` to remove one client.
I couldn't think of a pleasing approach for this problem. Any tips on how this could be solved are welcome.
Upvotes: 0
Views: 1805
Reputation: 130957
I'm just wondering what prevents you from using query parameters. They are the most appropriate way to filter a collection of resources in REST APIs. Using query parameters won't make your API less RESTful.
You could have the following:
GET /clients?status=authorized
GET /clients?status=unauthorized
Another option is:
GET /clients/authorized
GET /clients/unauthorized
You really should consider query parameters though.
Upvotes: 2
Reputation: 64943
I would go with /clients/unauthorized
and /clients/authorized
. You need to taylor resource URIs like directories.
This way, there's nothing wrong with deleting clients against the /client/[id]
resource.
Upvotes: 0