The API supports filtering results using facet filters. The recommended method is to use the tn_filters parameter, which allows multiple filters to be combined in a single query parameter.
These apply to the endpoints that support filtering:
Default Format: tn_filters
tn_filtersApply one or more filters using the tn_filters parameter. The value should be a URL-encoded string of key-value pairs:
tn_filters=urlencoded([urlkey]=[value1]|value2][&...])- [urlkey]: the key of the facet (e.g., color, brand, size)
- [value1]|[value2]: one or more values (encoded) for a facet, separated by |
- multiple filters are separated with &
- the full string must be URL-encoded
If tn_filters is not present in the URL, we will automatically fall back to the alternative format. This is also the case if the parameter is empty. To prevent this behavior, you can use tn_use_filters=true.
?tn_filters=&tn_use_filters=trueExample: Filter by one facet
?tn_filters=color=red|blue
Encoding example
Filter on `energy_label=A++`
- URL-encode individual values: A++ becomes A%2B%2B
- Construct the inner filter string: Combine the key and encoded value: energy_label=A%2B%2B
- URL-encode that entire string: Because this string is being passed as a value for the tn_filters parameter, the whole thing from step 2 must be encoded again: energy_label%3DA%252B%252B
- Append to the main URL: &tn_filters=energy_label%3DA%252B%252B
Range facet
The range facet is a special filter, that requires a different format:
[urlkey]=[min]-[max]
Example: price between 100 and 200.
?tn_filters=price%3D100-200
Alternative format: individual parameters
You can also apply filters using separate query parameters for each facet:
tn_fk_[urlkey]=[value1]|[value2]
Example
?tn_fk_color=red|blue&tn_fk_brand=nike
This has the same effect as the tn_filters example above.
Note: these do not have to be encoded.
Range facet
The range facet is a special filter, that requires a different format:
tn_fk_[urlkey]=[min]-[max]
Notes
- While both formats are supported,
tn_filtersis preferred, especially when working with the API specification. - When using
tn_filters, the individualtn_fk_parameters must not be used. Iftn_filtersis in use, any individual parameters will be ignored. - If
tn_filtersis not present in the URL, we will automatically fall back to the alternative format. This is also the case if the parameter is empty. To prevent this behavior, you can usetn_use_filters=true
