I am designing a flexible web service to aggregate data.
If we use sales as an example. A sales resource has properties of:
- Sales person
- Product
- Price
- Customer
- Id
- Department
- Date
- etc.
So the basic URI to access sales would be similar to the following:
api/sales/{id}
I need to design URIs to meet the following requirements:
- Total number of sales for a department
- Total number of sales for a person of a product
- month
So, three basic requirements. Grouping, filtering and selection of results (analogous to GROUP BY, WHERE and SELECT).
How to design the URI? The real problem for me is how to design the grouping. Here are some ideas I have been considering:
Keep the current URI design but add additional parameters:
E.g
/api/sales?groupby=department&groupby=customer
New URI:
/api/sales-aggregator?groupby=department&groupby=customer
Including the grouping as part of the path:
/api/sales-aggregator/department/customer
But the order of department and customer is arbitrary.
Alternative path solution
/api/sales-aggregator;groupby=department,groupby=customer
Recommendations?