> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fourthwall.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetching Products

> How to fetch products using the Storefront API

The Storefront API organizes products into **collections**. There is no standalone "List Products" endpoint—instead, you fetch products through collections.

## The `all` Collection

Every shop has a built-in `all` collection that contains all public products. This is the easiest way to get all products:

```javascript theme={null}
// Get all products
const res = await fetch(
  "https://storefront-api.fourthwall.com/v1/collections/all/products?storefront_token=YOUR_TOKEN"
);
const { results, paging } = await res.json();
```

## Common Patterns

### Get all products (paginated)

```javascript theme={null}
async function getAllProducts(token) {
  const products = [];
  let page = 0;
  let hasMore = true;

  while (hasMore) {
    const res = await fetch(
      `https://storefront-api.fourthwall.com/v1/collections/all/products?storefront_token=${token}&page=${page}&size=50`
    );
    const data = await res.json();
    products.push(...data.results);
    hasMore = data.paging.hasNextPage;
    page++;
  }

  return products;
}
```

### Get products from a specific collection

```javascript theme={null}
const res = await fetch(
  "https://storefront-api.fourthwall.com/v1/collections/merch/products?storefront_token=YOUR_TOKEN"
);
```

### Get a single product by slug

Use this when you already know the product slug (e.g., from a URL like `/products/cool-t-shirt`):

```javascript theme={null}
const res = await fetch(
  "https://storefront-api.fourthwall.com/v1/products/cool-t-shirt?storefront_token=YOUR_TOKEN"
);
```

## Why Collections?

Collections let you:

* Organize products into categories (e.g., "Apparel", "Accessories")
* Control which products appear on your storefront
* Create featured or seasonal groupings

The `all` collection is always available as a catch-all.
