Sort collections

United States
Canada
Europe
Latin America

Most JSON responses take the form of collections, which can be sorted by adding the orderBy query parameter. You can specify multiple fields by separating them with commas.

$ curl -s "https://apisandbox.dev.clover.com/v3/merchants/{mId}/items?orderBy=modifiedTime,price" --header "Authorization: Bearer {API_Token}" | python -mjson.tool

{
    "elements": [
        {
            "code": "",
            "defaultTaxRates": false,
            "hidden": false,
            "id": "V33H8XGTZCKNP",
            "isRevenue": true,
            "name": "Item Use",
            "price": 100,
            "priceType": "PER_UNIT",
            "unitName": "hr"
        },
        {
            "code": "",
            "defaultTaxRates": false,
            "hidden": false,
            "id": "EWKZEMNCBQQ9Y",
            "isRevenue": true,
            "name": "Nontax Item",
            "price": 100,
            "priceType": "FIXED",
            "unitName": "oz"
        },
...

The default sort order is descending by creation time. You can manually order by ascending or descending by inputting %20ASC or %20DESC, respectively.

$ curl -s https://apisandbox.dev.clover.com/v3/merchants/{mId}/items?orderBy=modifiedTime%20ASC --header "Authorization: Bearer {API_Token}" | python -mjson.tool

{
  "elements": [ {
      "id": "1CF022RN5TGDM",
      "hidden": false,
      "name": "Pizza Slice",
      "price": 250,
      "priceType": "FIXED",
      "defaultTaxRates": true,
      "cost": 0,
      "isRevenue": true
    }, {
      "id": "SNGFTY41642NY",
      "hidden": false,
      "name": "Pork Rice Bowl with House Salad",
      "price": 1200,
      "priceType": "FIXED",
      "defaultTaxRates": true,
      "cost": 0,
      "isRevenue": true,
      "stockCount": 3
    },
...