REST design : GET with groupBy parameter

3,475 views
Skip to first unread message

bruno roussel

unread,
May 18, 2015, 2:33:01 PM5/18/15
to api-...@googlegroups.com
Hi APICrafters,

I am wondering what would be the best design approch regarding a REST API where I need to get resources grouped by type.
Let me explain with this exemple:

GET /cars : return an array of all cars
GET /cars?groupBy=brand : return an array of brands. Each brand contains an array of cars

How does it sound to you ?
Would you recommend an other approch ?

Thanks, Bruno

bruno roussel

unread,
May 18, 2015, 2:35:32 PM5/18/15
to api-...@googlegroups.com
Forgot the second approch :

GET /brands?field=cars : return an array of brands. Each brand contains an array of cars.

Chris Mullins

unread,
May 18, 2015, 3:50:26 PM5/18/15
to api-...@googlegroups.com
You may take a look at the ODataV4 syntax around GroupBy

There may be some good ideas, or even the exact syntax, you can use. Their thinking around aggregation, roll ups, and grouping is interesting and hopefully helpful. 

Cheers,
Chris
Reply all
Reply to author
Forward
0 new messages