> ## Documentation Index
> Fetch the complete documentation index at: https://strapi-suite.littlebox.pt/llms.txt
> Use this file to discover all available pages before exploring further.

# Catalog

> List and show products, categories and collections.

Catalog routes need only the API token. They never read the session headers, so you can cache them with the framework's `REQUEST_REVALIDATE` value. Rate limit: `catalog`, 600 requests per minute per client IP.

```ts src/lib/store/catalog.ts theme={null}
import "server-only";
import { cache } from "react";
import { storeFetch, StoreApiError } from "./client";
import type { Pagination, Product, ProductListItem } from "./types";

const revalidate = Number(process.env.REQUEST_REVALIDATE ?? 60);

export type ProductQuery = {
  page?: number;
  pageSize?: number;
  search?: string;
  sort?: string;
  category?: string;
  collection?: string;
  tag?: string;
  locale: string;
};

export const listProducts = cache((query: ProductQuery) =>
  storeFetch<{ results: ProductListItem[]; pagination: Pagination }>("/products", { query, revalidate }),
);

export const getProduct = cache(async (slug: string, locale: string): Promise<Product | null> => {
  try {
    return await storeFetch<Product>(`/products/${encodeURIComponent(slug)}`, { query: { locale }, revalidate });
  } catch (error) {
    if (error instanceof StoreApiError && error.status === 404) return null;
    throw error;
  }
});
```

> [!NOTE]
>
> `available` in a cached answer can be a few seconds old. That is fine: every quote and every order checks the real
> stock again.

## List Products

`GET /products`

| Query | Type | Description |
| - | - | - |
| `page` | integer | Page number, from 1. Default `1`. |
| `pageSize` | integer | 1 to 50. Default `24`. |
| `search` | string | Matches the product name or a variant SKU (case insensitive, up to 100 characters; `%`, `_` and `\` are dropped). |
| `sort` | string | `newest` (default), `oldest`, `name_asc`, `name_desc`, `price_asc` (lowest variant price), `price_desc` (highest), `best_selling` (units sold in paid orders over the last 90 days). Ties go to the newest. With `collection` and no `sort`, the collection's own order applies. |
| `category` | string | A category slug. Matches the category **and its whole subtree**. |
| `collection` | string | A collection slug. Matches the collection's products. |
| `tag` | string | Comma separated tag ids (up to 50). Matches products with **any** of them. |
| `locale` | string | A Strapi locale. Default: the default locale. |

Filters combine with AND. Strapi looks up `category` and `collection` slugs in the request locale, then in the default locale. An unknown slug, an inactive collection, or an inactive category (or one under an inactive parent) answers `404 NOT_FOUND`. Unknown tag ids simply return an empty list. Tags have no slug: use the ids from the product answers.

```json Response 200 theme={null}
{
  "results": [
    {
      "id": 12,
      "slug": "littlebox-strapi-suite-t-shirt",
      "name": "Littlebox Strapi Suite T-Shirt",
      "shortDescription": "Soft organic cotton tee.",
      "image": {
        "url": "/uploads/t_shirt_black_9f1c2a.jpg",
        "width": 1200,
        "height": 1500,
        "alt": "Littlebox Strapi Suite T-Shirt",
        "cover": true
      },
      "priceMin": 2500,
      "priceMax": 2900,
      "compareAtPriceMin": 3200,
      "currency": "EUR",
      "available": true,
      "category": {
        "id": 4,
        "name": "T-Shirts",
        "slug": "t-shirts",
        "path": [
          { "id": 1, "name": "Apparel", "slug": "apparel" },
          { "id": 4, "name": "T-Shirts", "slug": "t-shirts" }
        ]
      },
      "tags": [{ "id": 7, "name": "Organic" }]
    }
  ],
  "pagination": { "page": 1, "pageSize": 24, "total": 1, "pageCount": 1 }
}
```

* `image` is the product's cover, else the cover of its first active variant.
* `compareAtPriceMin` is the "was" price of the cheapest variant, only when it is higher than its price, else `null`.
* `category` is `null` when the product has none, or when it or a parent is inactive. `path` runs from the root to the category itself, ready for a breadcrumb.

Errors: `400` with `invalid_number` (`page`, `pageSize`), `invalid_sort`, `invalid` (`tag`, or a repeated `category` or `collection`), `invalid_locale`; `404 NOT_FOUND` for an unknown filter slug.

```tsx src/app/(store)/shop/page.tsx theme={null}
import Link from "next/link";
import { getLocale } from "next-intl/server";
import { listProducts } from "@/lib/store/catalog";
import { formatMoney } from "@/lib/store/money";

export default async function ShopPage({
  searchParams,
}: {
  searchParams: Promise<{ page?: string; search?: string; sort?: string; category?: string }>;
}) {
  const { page, search, sort, category } = await searchParams;
  const locale = await getLocale();
  const { results, pagination } = await listProducts({
    page: Number(page) || 1,
    search,
    sort,
    category,
    locale,
  });
  return (
    <main>
      <ul>
        {results.map((product) => (
          <li key={product.id}>
            <Link href={`/shop/products/${product.slug}`}>
              {product.name} · {formatMoney(product.priceMin, locale)}
              {!product.available && " · Sold out"}
            </Link>
          </li>
        ))}
      </ul>
      <p>
        Page {pagination.page} of {pagination.pageCount}
      </p>
    </main>
  );
}
```

## Get a Product

`GET /products/:slug?locale=`

Strapi looks the slug up in the request locale, then in the default locale. An unknown product, an inactive one, or one without active variants answers `404 NOT_FOUND`.

```json Response 200 theme={null}
{
  "id": 12,
  "slug": "littlebox-strapi-suite-t-shirt",
  "slugs": { "en": "littlebox-strapi-suite-t-shirt", "pt": "t-shirt-littlebox-strapi-suite" },
  "name": "Littlebox Strapi Suite T-Shirt",
  "shortDescription": "Soft organic cotton tee.",
  "description": "<p>Made from 100% organic cotton.</p>",
  "images": [
    { "url": "/uploads/t_shirt_black_9f1c2a.jpg", "width": 1200, "height": 1500, "alt": "Littlebox Strapi Suite T-Shirt", "cover": true }
  ],
  "currency": "EUR",
  "priceMin": 2500,
  "priceMax": 2900,
  "compareAtPriceMin": 3200,
  "available": true,
  "category": { "id": 4, "name": "T-Shirts", "slug": "t-shirts", "path": [{ "id": 1, "name": "Apparel", "slug": "apparel" }, { "id": 4, "name": "T-Shirts", "slug": "t-shirts" }] },
  "tags": [{ "id": 7, "name": "Organic" }],
  "variants": [
    {
      "id": 31,
      "option": "Black / M",
      "sku": "LSS-TEE-BLK-M",
      "price": 2500,
      "compareAtPrice": 3200,
      "taxRate": 23,
      "available": true,
      "images": [{ "url": "/uploads/t_shirt_black_9f1c2a.jpg", "width": 1200, "height": 1500, "alt": "Littlebox Strapi Suite T-Shirt", "cover": true }]
    },
    {
      "id": 32,
      "option": "White / XL",
      "sku": "LSS-TEE-WHT-XL",
      "price": 2900,
      "compareAtPrice": null,
      "taxRate": 23,
      "available": false,
      "images": [{ "url": "/uploads/t_shirt_white_41b7d0.jpg", "width": 1200, "height": 1500, "alt": "Littlebox Strapi Suite T-Shirt", "cover": true }]
    }
  ]
}
```

* `description` is HTML that Strapi sanitizes on save against an allow list, so you can render it with `dangerouslySetInnerHTML`.
* A variant without its own images carries the product images.
* `slugs` holds the slug per locale. Use it for `hreflang` links and for the language switcher.
* Use the variant `id` in the cart.

```tsx src/app/(store)/shop/products/[slug]/page.tsx theme={null}
import { notFound } from "next/navigation";
import { getLocale } from "next-intl/server";
import { getProduct } from "@/lib/store/catalog";
import { formatMoney } from "@/lib/store/money";
import AddToCart from "./add-to-cart";

export default async function ProductPage({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  const locale = await getLocale();
  const product = await getProduct(slug, locale);
  if (!product) notFound();
  return (
    <main>
      <h1>{product.name}</h1>
      <div dangerouslySetInnerHTML={{ __html: product.description }} />
      <ul>
        {product.variants.map((variant) => (
          <li key={variant.id}>
            {variant.option} · {formatMoney(variant.price, locale)}
            {variant.compareAtPrice !== null && <s> {formatMoney(variant.compareAtPrice, locale)}</s>}
            <AddToCart variantId={variant.id} disabled={!variant.available} />
          </li>
        ))}
      </ul>
    </main>
  );
}
```

## List Categories

`GET /categories?locale=`

Returns the tree of active root categories. An inactive category hides its whole subtree. `children` come in the admin's order (`position`).

```json Response 200 theme={null}
[
  {
    "id": 1,
    "name": "Apparel",
    "slug": "apparel",
    "parentId": null,
    "position": 0,
    "children": [{ "id": 4, "name": "T-Shirts", "slug": "t-shirts", "parentId": 1, "position": 0, "children": [] }]
  }
]
```

## Get a Category

`GET /categories/:slug?locale=`

The same fields without `children`, plus `description`, `seoTitle` and `seoDescription` (`null` when empty) and `path` (the breadcrumb, root first). An unknown or inactive category, or one under an inactive parent, answers `404 NOT_FOUND`. List its products with `GET /products?category=:slug`.

```json Response 200 theme={null}
{
  "id": 4,
  "name": "T-Shirts",
  "slug": "t-shirts",
  "parentId": 1,
  "position": 0,
  "description": "Tees for every day.",
  "seoTitle": "T-Shirts | Littlebox Strapi Suite Store",
  "seoDescription": null,
  "path": [
    { "id": 1, "name": "Apparel", "slug": "apparel" },
    { "id": 4, "name": "T-Shirts", "slug": "t-shirts" }
  ]
}
```

## List Collections

`GET /collections?page=&pageSize=&locale=`

Returns the active collections sorted by title, paginated like the products (`pageSize` 1 to 50, default 24).

```json Response 200 theme={null}
{
  "results": [
    {
      "id": 2,
      "title": "Summer Picks",
      "slug": "summer-picks",
      "description": "Light pieces for warm days.",
      "seoTitle": null,
      "seoDescription": null
    }
  ],
  "pagination": { "page": 1, "pageSize": 24, "total": 1, "pageCount": 1 }
}
```

## Get a Collection

`GET /collections/:slug?locale=`

Returns one collection with the same fields. An unknown or inactive collection answers `404 NOT_FOUND`. List its products with `GET /products?collection=:slug`. The API never exposes whether a collection is manual or automated, nor its rules.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.