Sorting
This applies to V2 endpoints only.
Sort results that are returned from the API using the sort
parameter with the field name you want to sort against. By default, sort order is ascending. To sort in descending order, prefix the value with -
.
Currently, sorting is supported for the following endpoints, and against the following fields:
Endpoint | Fields to sort against |
---|---|
Customers | created_at , id , email , name , updated_at |
Orders | created_at , payment , shipping , status , with_tax |
User Authentication Info | created_at , id , updated_at |
Accounts | created_at , id , name , updated_at |
Account Members | created_at , id , email , name , updated_at |
Account Memberships | created_at , id , updated_at |
The following example shows how to make a request to get all products, and sort them by the created_at
timestamp.
Sort products by created_at
in ascending order
Curl
curl -X GET https://api.moltin.com/v2/products?sort=created_at
-H "Authorization: Bearer XXXX"
JavaScript SDK
// Where `EPCC` is an authenticated client
await EPCC.Products.All().Sort("created_at");
Sort products by created_at
in descending order
Curl
curl -X GET https://api.moltin.com/v2/products?sort=-created_at
-H "Authorization: Bearer XXXX"
JavaScript SDK
// Where `EPCC` is an authenticated client
await EPCC.Products.All().Sort("-created_at");