Purpose
- The
$filterparameter allows you to apply filtering criteria to the resources returned by the API.
Key Points
- Filters can be applied to the properties of the root resource.
- You can combine multiple filter criteria using logical operators and string functions.
- Filtering supports data types such as integer, big integer, double, decimal, string, date, and datetimeoffset.
- The API does not support filtering on nested resource properties.
Syntax of $filter Expression
- The expression follows the format:
[OPERATOR (PROPERTY_NAME, 'VALUE')]
- This means you can combine multiple conditions using logical operators.
[(contains(prod_ref,'ECx')) or (contains(prod_title,'App'))]
Supported Properties
- The list of available properties for the
Productresource can be found in the JSON schema returned by the/$metadataendpoints. - Example: When making a request to
/Products/$metadata, you will get a schema detailing all available properties likeprod_title,prod_ref, etc.
How to Use $filter in a Request
- When constructing your API request, add the
$filterparameter to specify the filtering conditions.
http://api2.saleslayer.com/rest/Catalog/Products?$select=prod_ref,prod_title&$filter=contains(prod_title,'EC')
Response Format
- When you use
$filter, the response will only contain resources that match the specified criteria.
{
"value": [
{
"prod_ref": "MyPer",
"prod_title": {
"en": "EC Personify"
}
}
],
"@count": 1,
"@readLink": "http://api2.saleslayer.com/rest/Catalog/Products?$select=prod_ref,prod_title&$filter=contains(prod_title,'EC')"
}Notes
- The
$filterparameter is a powerful tool for reducing the size of the response, especially when you're working with large datasets. - You should always refer to the metadata endpoint (e.g.,
/Products/$metadata) to confirm which properties are available for the resources you're working with.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article