'JSON API filtering standards for more complex queries
I am writing a REST api using ruby on rails. I am using json api as a guide for the standards to use when building the api.
I am trying to figure out the best way to use filtering in the GET requests. The json api recommendations for filtering only include where something is exactly equal to. eg.
GET /comments?filter[post]=1
How would I go about filtering for greater than, less than, not equal to, like, contains etc.?
I have done a lot of searching through google results but there doesn't seem to be a standard of the best way to do the filtering. There are some suggestions for example this one.
I'm looking for a solid spec or standard that I can refer to specifically for the filtering for my api, as the json api spec is very limited when it comes to filtering.
Solution 1:[1]
I looks like there are a few more resources for this now 6 years later.
From what I read quickly it looks like the JSON:API spec may not specify this exactly. However this supposedly compliant framework documentation looks helpful:
https://www.jsonapi.net/usage/reading/filtering.html
Going by their method you could do this
GET /games?filter=greaterThan(id,20345)
GET /games?filter=lessThan(id,345334)
See the link as they have a lot of other standard looking filters that could be useful.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | thinktt |
