# Variant Search

In order to search for all available Variants to you, you can use any of the following endpoints:

Both endpoints will return a list of search results. Each result represents a Variant with nested attributes for the associated Article.

Also both endpoints support further filtering with query parameters as described on the respective endpoint documentation.

# Example

We want to find all variants with the following criteria:

  • it should have a name including Deluxe
  • it should be a substrate
  • it should be of the supplier with the id: bc8206c6-bdea-42aa-8f1d-aa0f052a079e)
  • it should have a height of 920
  • it should have a width of 650

# Example Request

GET /substrate/bc8206c6-bdea-42aa-8f1d-aa0f052a079e/search?query=Deluxe&height=920&width=650

# Example Response

{
  "results": [
    {
      "id": "d825581f-00e0-49d0-830d-8dfd2b6cce08",
      "form": "sheet",
      "category": "PS5 - Wood-free Uncoated",
      "width": 650,
      "height": 920,
      "thickness": 102,
      "paper_weight": 80,
      "paper_weight_unit": "gsm",
      "grain": "long",
      "color": null,
      "transparency": null,
      "whiteness": null,
      "brightness": null,
      "roughness": null,
      "created_at": "2020-10-13T10:38:35.352Z",
      "updated_at": "2021-03-15T11:30:17.869Z",
      "dimensions_unit": "mm",
      "article": {
        "id": "34667bf6-9a74-4ed6-bec8-fae9211f1a26",
        "base_unit": "sheet",
        "coated": "none",
        "description": null,
        "finish": "UNCOATED",
        "kind": "paper",
        "name": "Paper Deluxe",
        "supplier_id": "bc8206c6-bdea-42aa-8f1d-aa0f052a079e,
        "supplier": {
          "id": "a8b99fd3-a790-4366-85b0-2df4af0ca000",
          "display_name": "Smith Paper",
          "brand_color": "#000000",
          "logo_url": "https://hub.sandbox.zaikio.com/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWxsWkRFMk9EQXlaaTAyT1RobExUUmpZVFF0WWpVeU5TMHdOamRsWVRnMFlXVXhaVFlHT2daRlZBPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--5f1d14251f9df052981ee7a68b24a55868b00e3f/image.png",
          "links": [
            {
              "rel": "self",
              "href": "/consumers/api/v1/suppliers/sappi"
            }
          ]
        },
        "created_at": "2020-10-13T10:38:32.083Z",
        "updated_at": "2021-03-16T13:31:05.232Z"
      },
      "available_environmental_certifications": [
        "PEFC 100%",
        "FSC Mix Credit",
        null
      ]
    }
  ],
  "facets": [
    {
      "name": "article_coated",
      "total_count": 18,
      "options": [
        {
          "value": "both sides",
          "count": 17
        },
        {
          "value": "none",
          "count": 1
        }
      ]
    },
    {
      "name": "article_finish",
      "total_count": 18,
      "options": [
        {
          "value": "SILK COATED",
          "count": 10
        },
        {
          "value": "GLOSS COATED",
          "count": 7
        },
        {
          "value": "UNCOATED",
          "count": 1
        }
      ]
    },
    {
      "name": "category",
      "total_count": 18,
      "options": [
        {
          "value": "PS1 - Premium Coated",
          "count": 17
        },
        {
          "value": "PS5 - Wood-free Uncoated",
          "count": 1
        }
      ]
    },
    {
      "name": "environmental_certifications",
      "total_count": 18,
      "options": [
        {
          "value": "FSC Mix Credit",
          "count": 18
        },
        {
          "value": "PEFC 100%",
          "count": 18
        }
      ]
    },
    {
      "name": "paper_weight",
      "total_count": 18,
      "options": [
        {
          "value": 115,
          "count": 2
        },
        {
          "value": 135,
          "count": 2
        },
        {
          "value": 150,
          "count": 2
        },
        {
          "value": 170,
          "count": 2
        },
        {
          "value": 200,
          "count": 2
        },
        {
          "value": 250,
          "count": 2
        },
        {
          "value": 300,
          "count": 2
        },
        {
          "value": 80,
          "count": 1
        },
        {
          "value": 90,
          "count": 1
        },
        {
          "value": 100,
          "count": 1
        },
        {
          "value": 350,
          "count": 1
        }
      ]
    },
    {
      "name": "thickness",
      "total_count": 18,
      "options": [
        {
          "value": 73,
          "count": 1
        },
        {
          "value": 76,
          "count": 1
        },
        {
          "value": 85,
          "count": 1
        },
        {
          "value": 91,
          "count": 1
        },
        {
          "value": 99,
          "count": 1
        },
        {
          "value": 102,
          "count": 1
        },
        {
          "value": 110,
          "count": 1
        },
        {
          "value": 111,
          "count": 1
        },
        {
          "value": 124,
          "count": 1
        },
        {
          "value": 140,
          "count": 1
        },
        {
          "value": 145,
          "count": 1
        },
        {
          "value": 148,
          "count": 1
        },
        {
          "value": 174,
          "count": 1
        },
        {
          "value": 190,
          "count": 1
        },
        {
          "value": 220,
          "count": 1
        },
        {
          "value": 246,
          "count": 1
        },
        {
          "value": 273,
          "count": 1
        },
        {
          "value": 343,
          "count": 1
        }
      ]
    },
    {
      "name": "width",
      "total_count": 20,
      "options": [
        {
          "value": 650,
          "count": 18
        },
        {
          "value": 640,
          "count": 2
        }
      ]
    }
  ]
}

# Understanding the returned facets

The response also includes a facets object. The facet object helps you to understand all the possible product criteria that your full result set includes. This allows you to easily specify further filters or create a filtered menu within your UI.

# Example Facet explained

The facet below tells you the following information about your result:

  • there's a total of 18 items that have the coated attribute on their Article
  • 17 of those have a value of both sides
  • 1 has a value of none, thus no coating
  "facets": [
    {
      "name": "article_coated",
      "total_count": 18,
      "options": [
        {
          "value": "both sides",
          "count": 17
        },
        {
          "value": "none",
          "count": 1
        }
      ]
    },

Please also note that the single options values don't necessarily need to add up to the total_count given any result found might have multiple values for one given attribute.