• API Overview/
    Sorting

    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:

    EndpointFields to sort against
    Customerscreated_at, id, email, name, updated_at
    Orderscreated_at, payment, shipping, status, with_tax
    User Authentication Infocreated_at, id, updated_at
    Accountscreated_at, id, name, updated_at
    Account Memberscreated_at, id, email, name, updated_at
    Account Membershipscreated_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");
    

    Was this helpful?

    Previous
    Filtering