# Product

The Ajax Product API returns the data of a product as JSON, for example to switch variants or show a quick view without reloading the page.

The Ajax Product API returns the data of a product as JSON, for example to switch variants or show a quick view without reloading the page.

## GET /products/{product-handle}.js

Returns the product as JSON. Instead of the [handle](https://developer.versacommerce.de/articles/liquid-basics-handle), you can also use the product access token or a custom URL of the product.

```javascript
fetch('/products/rain-coat.js')
  .then(response => response.json())
  .then(product => console.log(product.title));
```

Only active products of the current shop are returned. Password protection and configured redirects can affect the response.

Money values follow the price settings of the shop: in Shopify compatibility mode they are integers in cents.

## Response

```json
{
  "id": 329678821,
  "title": "Rain coat",
  "handle": "rain-coat",
  "description": "<p>Waterproof rain coat.</p>",
  "published_at": null,
  "created_at": "2026-03-12T16:28:13+01:00",
  "vendor": "Example Brand",
  "type": "Coats",
  "tags": ["Spring"],
  "price": 12900,
  "price_min": 12900,
  "price_max": 12900,
  "available": true,
  "price_varies": false,
  "compare_at_price": null,
  "compare_at_price_min": 0,
  "compare_at_price_max": 0,
  "compare_at_price_varies": false,
  "option1": "Size",
  "option2": null,
  "option3": null,
  "options": [
    { "name": "Size", "position": 1, "values": ["S", "M"] }
  ],
  "variants": [
    {
      "id": 794864229,
      "title": "S",
      "name": "Rain coat - S",
      "public_title": null,
      "options": ["S"],
      "option1": "S",
      "option2": null,
      "option3": null,
      "price": 12900,
      "compare_at_price": null,
      "weight": 0,
      "sku": "RC-S",
      "barcode": "49738645",
      "available": true,
      "inventory_quantity": 12,
      "inventory_management": "shopify",
      "inventory_policy": "deny",
      "requires_shipping": true,
      "taxable": true,
      "featured_image": null,
      "featured_media": null
    },
    {
      "id": 794864233,
      "title": "M",
      "name": "Rain coat - M",
      "public_title": null,
      "options": ["M"],
      "option1": "M",
      "option2": null,
      "option3": null,
      "price": 12900,
      "compare_at_price": null,
      "weight": 0,
      "sku": "RC-M",
      "barcode": "49738657",
      "available": true,
      "inventory_quantity": 4,
      "inventory_management": "shopify",
      "inventory_policy": "deny",
      "requires_shipping": true,
      "taxable": true,
      "featured_image": null,
      "featured_media": null
    }
  ],
  "images": ["https://cdn.example.com/products/rain-coat.jpg"],
  "featured_image": "https://cdn.example.com/products/rain-coat.jpg",
  "url": "/products/rain-coat"
}
```

Notes on the fields:

- `variants` also contains the main product row. A product without real variants has one variant with the title `Default Title`.
- `inventory_management` is `"shopify"` when stock is tracked for the variant, otherwise `null`. The value is kept for compatibility with existing theme scripts.
- `public_title` is `null`. `requires_shipping` and `taxable` are `true`.
- `published_at` is always `null` in this response.
- The product also has a `featured_media` key with the first media item.
- Image URLs are generated by VersaCommerce. Do not build them yourself; use the values from the response.
- Subscription data (`requires_selling_plan`, `selling_plan_groups`, `selling_plan_allocations`) is not part of the response, because selling plans are not supported.

## .js, .json and ?view=

The three ways to request a product behave differently:

| Request | Result |
|---|---|
| `/products/{handle}.js` | The JSON described above. The format is fixed and cannot be changed by the theme. |
| `/products/{handle}.json` | Rendered with the theme template `product_json` (with a built-in fallback). The JSON has a root key `product` and partly different fields, for example `base_price` for the unit price. |
| `/products/{handle}?view=NAME` | HTML page rendered with the template `product.NAME`, or `product` if it does not exist. Values containing `/` are ignored. |

`?view=` does not change the `.js` or `.json` output. With `section_id` or `sections` you can render single sections of the product page instead (see [Section Rendering API](https://developer.versacommerce.de/articles/section-rendering-api-introduction)).
