Skip to content
Guides
Queries

products

Search visible products and retrieve pagination and facets through GraphQL.

Last updated:

products queries the published catalog for the resolved store. Use this query for listings, search results, and collection or seller pages.

Signature

products(input: StorefrontProductsInput): SearchResult!

input is optional. If omitted, the API queries the first page with pageSize: 24 and the default sort order.

Input

FieldTypeDefaultRules
productIds[String!]No filterAt most 100 valid opaque IDs.
searchStringNo searchAt most 200 characters.
categories[String!]No filterAt most 50 values and 100 characters per value.
brands[String!]No filterAt most 50 values and 100 characters per value.
sellerSlugs[String!]No filterAt most 20 slugs and 100 characters per slug.
collections[String!]No filterAt most 50 values and 100 characters per value.
collectionIdStringNo filterValid opaque collection ID.
productTypes[ProductType!]No filterAt most 50 values.
tags[String!]No filterAt most 50 values and 100 characters per value.
filters[String!]No selected facetsAt most 100 filters and 250 characters per filter.
inStockBooleanNo filterWhen true, limits results to available products.
minPriceDecimalNo minimumMust be greater than or equal to 0.
maxPriceDecimalNo maximumMust be greater than or equal to 0 and to minPrice.
pageInt1Between 1 and 100.
pageSizeInt24Between 1 and 100.
sortProductSearchSortDEFAULTResult order.

Each filters value uses one of these forms:

option:name:value
attribute:name:value

You can select only one value for each product option. Attribute filters can be combined.

Enums

ProductType accepts PRODUCT, SERVICE, and BUNDLE.

ProductSearchSort accepts:

ValueUse
DEFAULTDefault catalog order.
PRICE_ASCLowest price first.
PRICE_DESCHighest price first.
NEWESTNewest products first.
NAME_ASCName in ascending order.
NAME_DESCName in descending order.

Return value

SearchResult contains:

FieldTypeDescription
pageIndexInt!Returned page.
pageSizeInt!Applied page size.
totalCountLong!Total number of matches.
totalPagesInt!Total number of pages.
products[ProductSummary!]!Products in the page.
filters[SearchFilter!]!Facets available to refine the query.

ProductSummary

FieldTypeFieldType
idString!nameString!
slugString!productTypeString!
imageUrlString!priceDecimal!
compareAtPriceDecimalvariantCountInt!
isAvailableBoolean!totalInventoryInt!
bundleItemsCountInt!brandString!
categoryString!statusString!
collections[String!]!tags[String!]!
sellerProductSellerInfo

ProductSellerInfo contains id, name, and slug, all String!.

Filters and facets

Each SearchFilter contains:

FieldTypeDescription
idString!Filter identifier.
labelString!Display label.
typeString!Filter type.
values[FacetItem!]!Available values and their counts.
minDecimalAvailable lower bound, when applicable.
maxDecimalAvailable upper bound, when applicable.
selectedMinDecimalSelected lower bound, when applicable.
selectedMaxDecimalSelected upper bound, when applicable.

Each FacetItem contains value: String!, count: Int!, label: String, and selected: Boolean!.

Query

Products.graphql
query Products($input: StorefrontProductsInput) {
  products(input: $input) {
    pageIndex
    pageSize
    totalCount
    totalPages
    products {
      id
      name
      slug
      productType
      imageUrl
      price
      compareAtPrice
      variantCount
      isAvailable
      totalInventory
      bundleItemsCount
      brand
      category
      status
      collections
      tags
      seller {
        id
        name
        slug
      }
    }
    filters {
      id
      label
      type
      min
      max
      selectedMin
      selectedMax
      values {
        value
        count
        label
        selected
      }
    }
  }
}

Variables:

Variables
{
  "input": {
    "search": "mug",
    "categories": ["Home"],
    "inStock": true,
    "page": 1,
    "pageSize": 24,
    "sort": "PRICE_ASC"
  }
}

cURL

Terminal
curl --request POST "https://storefront.ecomiq.pe/graphql" \
  --header "Content-Type: application/json" \
  --header "x-Store-Domain: my-store" \
  --data-binary '{
    "query": "query Products($input: StorefrontProductsInput) { products(input: $input) { pageIndex pageSize totalCount totalPages products { id name slug productType imageUrl price compareAtPrice variantCount isAvailable totalInventory bundleItemsCount brand category status collections tags seller { id name slug } } filters { id label type min max selectedMin selectedMax values { value count label selected } } } }",
    "variables": {
      "input": {
        "search": "mug",
        "categories": ["Home"],
        "inStock": true,
        "page": 1,
        "pageSize": 24,
        "sort": "PRICE_ASC"
      }
    }
  }'

Response

The API returns only the requested fields. This example uses the product summary values covered by the host contract:

Response
{
  "data": {
    "products": {
      "pageIndex": 1,
      "pageSize": 24,
      "totalCount": 1,
      "totalPages": 1,
      "products": [
        {
          "id": "789",
          "name": "Related mug",
          "slug": "related-mug",
          "productType": "Product",
          "imageUrl": "/related.jpg",
          "price": 12,
          "compareAtPrice": null,
          "variantCount": 1,
          "isAvailable": true,
          "totalInventory": 2,
          "bundleItemsCount": 0,
          "brand": "Acme",
          "category": "Home",
          "status": "Active",
          "collections": [],
          "tags": [],
          "seller": null
        }
      ],
      "filters": []
    }
  }
}

Errors

CodeCommon cause
BAD_USER_INPUTPage, size, price, ID, filter, or number of values is outside the contract.
NOT_FOUNDA requested collection does not exist or is not visible.
STORE_CONTEXT_REQUIREDx-Store-Domain did not resolve a store.

A GraphQL response can include errors with HTTP 200. See GraphQL errors.

On this page