Validate and test IQL

A validation endpoint is available for:

  • testing if the syntax of your IQL query is correct.
  • previewing the results of the IQL (function results, actual values of context attributes).
  • checking examples of items which match the IQL query.
  • checking if a particular item matches the IQL query.
Tip: This article presents one request example. For a complete list of all available options and response parameters, see the API reference.

Request

curl --location --request POST 'https://api.synerise.com/items/v2/filter/validate?itemsCatalogId=default' \
--header 'authorization: Bearer eyJhbG...66Wr4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "filteringString": "IF(\"vip\" IN client.tags, discount > context.discount, discount == 0)",
    "contextItems": ["549"],
    "candidateItems": ["302","413"],
    "clientUUID": "516e431d-c6d9-488e-b184-f8b15f93baeb"
}'

where

  • itemsCatalogId=default is the ID of the item feed which is the source for items tested by the query
  • filteringString is the complete IQL query (note the escaped quotes in the query)
  • contextItems is an array of context items, in this case it’s one item
  • candidateItems is an array of items to test against the filteringString
  • clientUUID is the identifier of the context profile

Response

{
    "filteringString": "IF(\"vip\" IN client.tags, discount > context.discount, discount == 0)",
    "contextItems": [
        "549"
    ],
    "clientUUID": "516e431d-c6d9-488e-b184-f8b15f93baeb",
    // informs if the IQL syntax (and only the syntax) is valid:
    "parserResult": {
        // processed filtering string:
        "parsedFilteringString": "IF(\"vip\" IN client.tags THEN discount > context.discount ELSE discount == 0.0)",
        "valid": true
    },
    // summary of context values used in the query. Details are available in the API reference.
    "extracts": {
        "clientExtracts": {
            "aggregateConstants": [],
            "attributeConstants": [],
            "expressionConstants": [],
            "segmentationsConstant": [],
            "tagsConstant": true
        },
        "contextConstants": [
            "discount"
        ],
        "variables": [
            "discount"
        ]
    },
    // results of running the query in context of the item feed and its configuration:
    "evaluationResult": {
        "evaluationErrors": [],
        // fully processed filtering string, with inserted values of context attributes:
        "modifiedFilteringString": "IF(\"vip\" IN [documentation,test,example] THEN discount > 0.0 ELSE discount == 0.0)",
        // the number of matching items:
        "resultsSize": 584
    },
    // results of checking particular items against the filter:
    "candidateItems": [
        {
            "itemId": "302",
            "valid": false
        },
        {
            "itemId": "413",
            "valid": true
        }
    ],
    // an array of example items which matched the filter:
    "exampleItems": [
        "100",
        "356",
        "257",
        "377",
        "358",
        "297",
        "136",
        "514",
        "196",
        "404"
    ]
}
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker