Purpose
- The
$filter
parameter 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 $select
Expression
- The expression follows the format:
[OPERATOR (PROPERTY_NAME, 'VALUE')]
- This means you can list multiple properties separated by commas.
[(contains(prod_ref,'ECx')) or (contains(prod_title,'App'))]
Supported Properties
- The list of available properties for the
Product
resource can be found in the JSON schema returned by the/$metadata
endpoints - 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 $select
in a Request
- When constructing your API request, add the
$select
parameter to specify the fields you want to retrieve
http://api2.saleslayer.com/rest/Catalog/Products?$select=[prod_ref,prod_title]&$filter=[contains(prod_title,'EC')]
Response Format
- When you use
$select
, the response will only contain the specified properties, making it more concise and efficient.
{
"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
$filter
parameter 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.