I am building a REST API that uses a filter
parameter to control search results. E.g., one could search for a user by calling:
GET /users/?filter=name%3Dfoo
Now, my API should allow many different filter
operators. Numeric operators such as equals
, greater than
, less than
, string operators like contains
, begins with
or ends with
and date operators such as year of
or timediff
. Moreover, AND
and OR
combinations should be possible.Basically, I want to support a subset of the underlying MySQL database operators.
I found a lot of different implementations (two good examples are Google Analytics and LongJump) that seem to use custom syntax.Looking at my requirements, I would probably design a custom syntax pretty similar to the MySQL operator syntax.
However, I was wondering if there are any best practices established that I should follow and whether I should consider anything else.