I would like create a REST endpoint which would allow a user to pass a query parameter that is incidentally a field of a taxonomy term. I am trying to achieve this by using Services Views in Drupal 7.
To simplify the problem, let's say I have a list of players and each player has a name and a skill level. For example, the unfiltered JSON output of my API would be
[{"name": "John98","level": "Beginner"}, ...
{"name": "PetePete", "level": "Advanced"}]
But the level is actually a taxonomy term, that also has a "min_points" integer field, for example 0 for "beginner" and 50 for "advanced" and 1000 for "expert".
In my API would like to do smth like http://example.com/api/players?points>45 and get all the players with levels that correspond to more than 45 points.
Is this possible to achieve? Thank you in advance for any input.
Views datasource
's sub module calledViews JSON
. Essentially you just build the View as you normally would, add the exposed filter, then append that filter to the URL when making the call for the JSON data:api/players?points=45
=
in the query string doesn't literally mean equality, it'll listen to whateverop
you have selected on your exposed filter. So if yourop
is set toless than
then the equal sign will listen to that op. As for the module not being covered by the security policy, I understand your concerns, but personally I've been using the module for about 7 years without issue in numerous production environments.