Let’s say I have a method that returns a list of customers and as input has a list of states and list of sizes, something like
return customers where state in (NY, CA, TX) and size in (Small, Medium)
What would the best RESTFul URL that I should use? The problem that it is a query and does not point to a specific ‘resource’. Here are some options that I am mulling over.
- somesite.com/customers?state=NY,CA,TX&size=small,medium (old style)
- somesite.com/customers/state/NY,CA,TX/size/small,medium
- somesite.com/customers/state=NY,CA,TX/size=small,medium
- somesite.com/customers/state(NY,CA,TX)/size(small,medium)
Personally, I’d use the 4th approach, but with the ‘+’ sign instead of parenthesis:
RESTful-style your Models are not necessarily all the RESTful Resources you should offer… You can add any number of (artificial) resources as you see fit, even ones that would require a JOINs from your Models.