We're designing a rest endpoint for retreiving name autocompletion suggestions for hotel names.
Currently it's defined like this: GET /suggest/:term
, so that if you queried `/suggest/hil' you would get responses like "Hilton Paris", "Hilton New York", etc.
One of our colleagues argues that this is against REST API design best practices, and that the search term should instead be a query parameter, i.e. /suggest?term=hilt
.
Looking around other famous APIs, it seems that they all use a query parameter:
- https://developers.google.com/places/webservice/autocomplete
- https://swiftype.com/documentation/autocomplete
but I'd like to know why; whether the former is actually bad design and what guidelines would get me to make it a query parameter in the first place.
term
being a unique resource identifier for suggestions was the way I had thought about it too. – Zoltán Aug 24 '15 at 14:38/user/:username
displaying user data could be expected to change. So why wouldn't suggestions also be allowed to change if identified by path? – Zoltán Aug 24 '15 at 14:41GET
request for a specific resource should always return the same resource without side-effects; the content of that resource may change, but it should be the same resource. – Mike Partridge Aug 24 '15 at 15:17