What is the best option to separate REST query search terms from options? -


let's have rest api /cars. if get /cars cars (if allowed). if want cars red, might get /cars?color=red.

now let's assume want sort them, options ascending vs descending.

get /cars?color=red&sort=asc

the problem here sort not search term, option. makes difficult server differentiate between search terms color=red , search options sort=asc.

it bad way design api, since 1 day might want use sort field can search on (as opposed option).

how people recommend constructing search api? here options have found:

  1. leave is, knowing fields are, definition, options , not terms.
  2. special flags search terms, e.g. search.color=red&search.year=2010&sort=asc
  3. special flags search options, e.g. color=red&year=2010&option.sort=asc
  4. special flag whole thing, e.g. search=[color=red&year=2010]&sort=asc (with [..] section url encoded)

thoughts?

how use of odata http://www.odata.org/documentation/odata-version-2-0/uri-conventions/

odata v2

get /cars?$orderby=rating asc /cars?$filter=color eq red /cars$filter=color eq red , year eq 2000&$skip=2&$top=2&$orderby=category/rating desc 

or check odata library , uri syntax of version 3 or 4. odata kind of standard , supported in .net , in java , javascript. there established libraries.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -