Gaming Filtering
Tag-Based Filtering
Smart Search supports tag-based filtering, enabling explicit data filtering through tags in conjunction with search queries. This can be useful for enabling features like buttons or filters in the front-end (FE) interface.
Request Body Breakdown:
- Body of the Request: The request body includes essential information like user traits, the search query, and the tag rules. Tag rules allow you to filter search results based on specific tags, such as suppliers or product categories.
- Purpose: Use tag-based filters to explicitly filter search results using predefined tags. This can help narrow down search results based on specific criteria, such as selecting products from a certain supplier.
When providing tag rules, you can set the query parameter to "", in order to return a list of games that adhere to the tag rules, without searchingfor any particular search terms.
Example Request:
import requests
import json
# API URL
url = "https://api.opti-x.optimove.net/search/v1/query"
# Headers
headers = {
"accept": "application/json",
"x-api-key": "your_api_key",
"x-brand-key": "your_brand_key",
"Content-Type": "application/json"
}
# Tag rules
tag_rules = [
{
"rule": {
"tags": [
{
"tag": "Blue Print",
"tag_type": "supplier"
}
],
},
"rule_type": "IS_IN"
}
]
# Payload
payload = {
"traits": {
"license": "string",
"currency": "string",
"language": "string"
},
"query": "irish",
"context": {},
"skinId": "string",
"location": {
"country": "string",
},
"tag_rules": tag_rules,
"type": "search",
"userId": "test_user",
}
# Make the POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))
# Output the response
print("Status Code:", response.status_code)
print("Response:", response.json())
Example cURL Request:
curl -X POST "https://api.opti-x.optimove.net/search/v1/query" \
-H "accept: application/json" \
-H "x-api-key: your_api_key" \
-H "x-brand-key: your_brand_key" \
-H "Content-Type: application/json" \
-d '{
"traits": {
"license": "string",
"currency": "string",
"language": "string"
},
"query": "irish",
"context": {},
"skinId": "string",
"location": {
"country": "string"
},
"tag_rules": [
{
"rule": {
"tags": [
{
"tag": "Blue Print",
"tag_type": "supplier"
}
]
},
"rule_type": "IS_IN"
}
],
"type": "search",
"userId": "test_user"
}'
Expected Results:
- Without tag rules: If you remove the
tag_rules
from the request, you might get a higher number of results, e.g.,'result_count': 49
. - With tag rules: By applying the
tag_rules
, such as filtering by the "Blue Print" supplier, the result count can be reduced, e.g.,'result_count': 5
.
You can test and verify the filtered results by inspecting the tags or providers in the search results:
[i["tags"] for i in response.json()['result']['search_results']]
[i["provider"] for i in response.json()['result']['search_results']]
This should return:
['Blue Print', 'Blue Print', 'Blue Print', 'Blue Print', 'Blue Print']
This confirms that the tag_rules
have successfully filtered the search_results
.
Constraints:
- Tag Rules Complexity: Tag rules can be quite complex, allowing for a combination of logic such as OR/AND, multiple tags, and different operators (e.g.,
IS_IN
,NOT_IN
). - Structure: While the tag rule logic and structure offer flexibility, replicating all possible combinations in some environments may require additional effort.
Region-Based Filtering
Smart Search supports region-based filtering, enabling search results and popular searches to consider the user's country. This ensures users receive content that is relevant to their location.
Request Body Breakdown
- Location Information: Include the
location
field in your request body to specify the user's country using a country code (e.g.,"GB"
for Great Britain,"US"
for the United States). - Purpose: By providing the country code, the API returns region-specific popular searches and rankings. If the country code is omitted or no regional data is available, the API defaults to global data.
Example Request
import requests
import json
# API URL
url = "https://api.opti-x.optimove.net/search/v1/popular"
# Headers
headers = {
"accept": "application/json",
"x-api-key": "your_api_key",
"x-brand-key": "your_brand_key",
"Content-Type": "application/json"
}
# Payload with location info
payload = {
"location": {
"country": "GB" # Specify the country code
}
}
# Make the POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))
# Output the response
print("Status Code:", response.status_code)
print("Response:", response.json())
Example cURL Request
curl -X POST "https://api.opti-x.optimove.net/search/v1/popular" \
-H "accept: application/json" \
-H "x-api-key: your_api_key" \
-H "x-brand-key: your_brand_key" \
-H "Content-Type: application/json" \
-d '{
"location": {
"country": "GB"
}
}'
Expected Results
- With
location.country
specified: The API returns popular searches specific to the provided country code ("GB"
in this example), if regional data is available. - Without
location.country
specified: The API defaults to global popular searches and rankings.
Notes
- Fallback to Global Data: If regional data isn't available for the specified country, the API automatically uses global data.
- Country Code: The value for
location.country
is case-insensitive. - Example Country Codes: Use standard country codes like
"GB"
for Great Britain or"US"
for the United States.
Updated 20 days ago