Filtering and sorting

Filtering

You can filter out collection results by applying filter parameters to your API calls, eg.

curl --request GET \
     --url 'https://demo.getvendo.com/api/v2/storefront/products?filter%5Bskus%5D=classic-varsity-top-large' \
     --header 'Accept: application/vnd.api+json'

You can combine multiple filters to find only records that match both criteria:

curl --request GET \
     --url 'https://demo.getvendo.com/api/v2/storefront/products?filter%5Bprice%5D=10%252C100&filter%5Bname%5D=Classic%2520Varsity' \
     --header 'Accept: application/vnd.api+json'

Additionally, some resources such as Products will return a meta[filters] node:

{
  "option_types": [
    {
      "id": "143b3650-0f2f-49d2-8514-9efa52bc8cf0",
      "name": "size",
      "presentation": "Size",
      "option_values": [
        {
          "id": "111369fc-17bd-4326-a7c5-13cff4c9f643",
          "name": "Small",
          "presentation": "Small",
          "position": 1
        },
        {
          "id": "69485fa2-3fc3-4d12-9b25-af2cbe2ac0bd",
          "name": "Medium",
          "presentation": "Medium",
          "position": 2
        },
        {
          "id": "b7838bbb-e498-4971-9dfa-de9f1b19cc28",
          "name": "Large",
          "presentation": "Large",
          "position": 3
        },
        {
          "id": "6230833e-402b-4410-aad8-c1bdd8c04e7b",
          "name": "XS",
          "presentation": "XS",
          "position": 4
        },
        {
          "id": "45aabc6c-7a31-42cf-81c1-9f812137d7a6",
          "name": "M",
          "presentation": "M",
          "position": 5
        },
        {
          "id": "5906859d-a0bf-4430-a79e-0ab76e362bb2",
          "name": "S",
          "presentation": "S",
          "position": 6
        }
      ]
    },
    {
      "id": "0a4ebc9d-1804-48f0-b056-ef2bf4c0a97d",
      "name": "color",
      "presentation": "Color",
      "option_values": [
        {
          "id": "400b7c06-7753-4f04-bd94-d359da8620bc",
          "name": "Black",
          "presentation": "Black",
          "position": 3
        },
        {
          "id": "ac892677-eaea-4bd1-b3f7-2e0ae63a04d6",
          "name": "Red",
          "presentation": "Red",
          "position": 4
        },
        {
          "id": "61e4e9ad-d581-4811-8c95-e4f654d967f3",
          "name": "Blue",
          "presentation": "Blue",
          "position": 5
        },
        {
          "id": "dde2645b-be14-4bfc-b881-85a19c4a690a",
          "name": "Brown",
          "presentation": "Brown",
          "position": 6
        },
        {
          "id": "e69dfd4f-503a-4d3b-8f98-00d617bea5ee",
          "name": "White",
          "presentation": "White",
          "position": 7
        },
        {
          "id": "991533b6-c69d-4179-8804-9b443863f978",
          "name": "Yellow",
          "presentation": "Yellow",
          "position": 8
        },
        {
          "id": "3d66e314-7bc5-4dd9-9e43-c1df5f213537",
          "name": "Gray",
          "presentation": "Gray",
          "position": 9
        },
        {
          "id": "38b9703d-a3b5-4ec7-9e9f-1d87ce2c5a2e",
          "name": "Purple",
          "presentation": "Purple",
          "position": 10
        }
      ]
    },
    {
      "id": "aa1cc85e-4cb8-4fe8-b700-d624175a430d",
      "name": "Width",
      "presentation": "Width",
      "option_values": [
        {
          "id": "10f798de-1c96-409b-a165-0ffa3a357950",
          "name": "Medium",
          "presentation": "Medium",
          "position": 1
        },
        {
          "id": "64e78136-e389-4064-8841-431c787d0f91",
          "name": "Large",
          "presentation": "Large",
          "position": 2
        },
        {
          "id": "3aefa492-6091-4685-8456-19444f82af2a",
          "name": "Small",
          "presentation": "Small",
          "position": 3
        }
      ]
    },
    {
      "id": "d20d728d-d2eb-401e-af3d-68a0a4174284",
      "name": "Flavour",
      "presentation": "Flavour",
      "option_values": [
        {
          "id": "907e6060-4f0c-4382-8508-38f47d446ca7",
          "name": "Spinach",
          "presentation": "Spinach",
          "position": 1
        },
        {
          "id": "2899166f-b35f-4e74-95f1-1f96ad947cd8",
          "name": "Apple",
          "presentation": "Apple",
          "position": 2
        }
      ]
    },
    {
      "id": "d364e7d4-885d-4fb8-b3b5-ea9f3276d110",
      "name": "Cultivar",
      "presentation": "Cultivar",
      "option_values": [
        {
          "id": "a73adc38-a5d0-4bf8-82d5-cc8ef3b3f284",
          "name": "McIntosh",
          "presentation": "McIntosh",
          "position": 1
        }
      ]
    }
  ],
  "product_properties": []
}

This is generated based on your Store attributes - https://your_store.getvendo.com/admin/option_types

Products list endpoint covers how to filter by these attributes in more detail.

Sorting

Sorting is being performed by supplying sort parameter in your API calls.

Ascending sort, eg.

curl --request GET \
     --url 'https://demo.getvendo.com/api/v2/storefront/products?sort=price' \
     --header 'Accept: application/vnd.api+json'

Descending sort is performed by adding - before the column name, eg:

curl --request GET \
     --url 'https://demo.getvendo.com/api/v2/storefront/products?sort=-price' \
     --header 'Accept: application/vnd.api+json'

You can also combine multiple attributes:

curl --request GET \
     --url 'https://demo.getvendo.com/api/v2/storefront/products?sort=-price%252Cupdated_at' \
     --header 'Accept: application/vnd.api+json'

Each endpoint includes a list of attributes you can sort by. The default ones are always id, created_at, updated_at and name.