Purpose
- The
$orderbyparameter specifies the sorting of the returned results based on one or more properties.
Key Points
- You can specify the sorting order (ascending or descending) of a resource property.
- Sorting is supported only on properties of the root resource.
- By default, the order is ASC by creation date.
Syntax of $orderby Expression
- The expression follows the format:
PROPERTY_NAME (asc)|desc
- Example
cat_ref asc
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 $orderby in a Request
- When constructing your API request, add the
$orderbyparameter to specify the fields you want to retrieve.
http://api2.saleslayer.com/rest/Catalog/Products?$select=prod_ref,cat_ref,prod_description&$orderby=prod_ref asc
Response Format
- When constructing your API request, add the
$orderbyparameter to specify how the results should be sorted. The response will include the results sorted according to the specified order.
{
"value": [
{
"prod_ref": "Atrius",
"cat_ref": "OMA",
"prod_description": {
"en": "Atrius"
}
},
{
"prod_ref": "Zatrius",
"cat_ref": "OMA",
"prod_description": {
"en": "Zatrius"
}
}
],
"@count": 2,
"@readLink": "http://api2.saleslayer.com/rest/Catalog/Products?$select=prod_ref,cat_ref,prod_description&$orderby=prod_ref asc"
}
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