Skip to content

list-products

Method: GET
Path: /catalog/products

Tags: Catalog

Summary

List all products

Description

Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.

Storefront SDK Usage

SDK Method: sdk.catalog.listProducts()

Example:

typescript
// Basic product listing
const { data, error } = await sdk.catalog.listProducts();

if (error) {
  console.error("Failed to list products:", error);
  return;
}

console.log("Products found:", data.products?.length || 0);
console.log("Pagination:", data.pagination);

// With filtering and pagination
const { data: filteredData, error: filteredError } = await sdk.catalog.listProducts({
  page: 1,
  limit: 20,
  sort_by: JSON.stringify({ "created_at": "desc" }),
  category_slug: ["electronics", "smartphones"]
});

// Override customer group ID for this specific request
const { data: overrideData, error: overrideError } = await sdk.catalog.listProducts(
  {
    page: 1,
    limit: 20,
    sort_by: JSON.stringify({ "created_at": "desc" }),
    category_slug: ["electronics", "smartphones"]
  },
  {
    "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
  }
);

if (filteredError) {
  console.error("Failed to get filtered products:", filteredError);
  return;
}

filteredData.products?.forEach(product => {
  console.log(`Product: ${product.name} - ${product.price}`);
});

TypeScript Definition

typescript
"list-products": {
        parameters: {
            query?: {
                /** @description page number of pagination list */
                page?: components["parameters"]["pageParam"];
                /** @description no of rows per page */
                limit?: components["parameters"]["pageLimitParam"];
                /** @description JSON string format: {"field1":"asc", "field2":"desc"} */
                sort_by?: components["parameters"]["sortingParam"];
                /** @description filter products by categories ids */
                category_id?: string[];
                /** @description filter products by categories slugs */
                category_slug?: string[];
                /** @description Determines whether to include or exlude inventory details in response json */
                inventory?: boolean;
            };
            header?: {
                /** @description This param is used to determine product pricing, promotions, and subscription rates.  If a valid customer group id is provided, pricing details will be retrieved accordingly.  If no matching data is found for the specified customer group id, the system will fall back to the default customer group id.  If no data is found for the default group either, the highest applicable price will be returned. */
                "x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
            };
            path?: never;
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description Success response */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /** @example Products retrieved successfully. */
                        message: string;
                        success: boolean;
                        content: {
                            products: components["schemas"]["Product"][];
                            pagination: components["schemas"]["Pagination"];
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
            404: components["responses"]["NotFound"];
        };
    };

Component References

ReferenceResolves To
components["parameters"]["pageParam"]pageParam
components["parameters"]["pageLimitParam"]pageLimitParam
components["parameters"]["sortingParam"]sortingParam
components["parameters"]["CustomerGroupId"]CustomerGroupId
components["schemas"]["Product"]Product
components["schemas"]["Pagination"]Pagination
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["NotFound"]NotFound

Parameters

  • page (query): page number of pagination list
  • limit (query): no of rows per page
  • sort_by (query): JSON string format: {"field1":"asc", "field2":"desc"}
  • x-customer-group-id (header): This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned.
  • category_id (query): filter products by categories ids
  • category_slug (query): filter products by categories slugs
  • inventory (query): Determines whether to include or exlude inventory details in response json

Responses

200

Success response

401

Not authorized for given operation on the Resource

404

Requested resource not found

OpenAPI Definition

json
{
  "tags": [
    "Catalog"
  ],
  "operationId": "list-products",
  "summary": "List all products",
  "description": "Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/list-products",
    "description": "API reference for the list-products operation"
  },
  "parameters": [
    {
      "$ref": "#/components/parameters/pageParam"
    },
    {
      "$ref": "#/components/parameters/pageLimitParam"
    },
    {
      "$ref": "#/components/parameters/sortingParam"
    },
    {
      "$ref": "#/components/parameters/CustomerGroupId"
    },
    {
      "name": "category_id",
      "in": "query",
      "description": "filter products by categories ids",
      "schema": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "explode": true,
      "style": "form"
    },
    {
      "name": "category_slug",
      "in": "query",
      "description": "filter products by categories slugs",
      "schema": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    {
      "name": "inventory",
      "in": "query",
      "description": "Determines whether to include or exlude inventory details in response json",
      "schema": {
        "type": "boolean"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Success response",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string",
                "examples": [
                  "Products retrieved successfully."
                ]
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "products": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Product"
                    }
                  },
                  "pagination": {
                    "$ref": "#/components/schemas/Pagination"
                  }
                },
                "required": [
                  "products",
                  "pagination"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "catalog",
  "x-speakeasy-ignore": false,
  "x-speakeasy-name-override": "listProducts"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: