Sorting results

When you fetch a collection of resources, you can request a specific sort for the results. For example, the following request fetches a collection of SKUs sorted by their creation date (descending) and code.

GET /api/skus/1234?sort=-created_at,code HTTP/1.1
Accept: application/vnd.api+json

The value of the sort parameter must be a comma-separated list of fields. The sort order for each field is ascending unless prefixed with a - (minus) in which case it's descending. By default, the API sorts ascending on the id of the primary resource.

Note: You can get the full list of sortable attributes from the documentation of each resource.

Get our machine-readable JSON schema that follows the OpenAPI Specification (formerly Swagger).

Get our Postman collection in one click and start making real calls to Commerce Layer API in minutes.

Get in touch with our support team if you have any questions or want to learn more about Commerce Layer.