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

# Product and menu

> Read a product page or a restaurant menu into a fixed shape with variants, prices and stock. Each adds $3 per 1,000 pages to the $1 page price.

`product` reads a product page into one object with its variants, prices and stock. `menu` reads a restaurant menu into sections of items with prices. The shape is fixed, so the same code works on every shop and every menu.

## Read a product

Get an API key in the [Quickstart](https://docs.stophy.dev/quickstart). This request reads a book page of a shop.

```bash cURL theme={null}
curl -X POST https://api.stophy.dev/v1/scrape \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
    "formats": ["product"]
  }'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.stophy.dev/v1/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.STOPHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
    formats: ["product"],
  }),
});
const { data } = await response.json();
console.log(data.product.title);
console.log(data.product.variants[0].price);
```

```python Python theme={null}
import os

import requests

response = requests.post(
    "https://api.stophy.dev/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['STOPHY_API_KEY']}"},
    json={
        "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
        "formats": ["product"],
    },
)
data = response.json()["data"]
print(data["product"]["title"])
print(data["product"]["variants"][0]["price"])
```

## Read the response

`data.product` holds the product. This real response is cut in the description.

```json theme={null}
{
  "success": true,
  "data": {
    "product": {
      "title": "A Light in the Attic",
      "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
      "description": "It's hard to imagine a world without A Light in the Attic. This now-classic collection of poetry and drawings from Shel Silverstein celebrates its…",
      "variants": [
        {
          "sku": "a897fe39b1053632",
          "price": {
            "amount": 51.77,
            "currency": "GBP",
            "formatted": "£51.77"
          },
          "availability": {
            "inStock": true,
            "text": "In stock (22 available)"
          },
          "images": [
            {
              "url": "http://books.toscrape.com/media/cache/fe/72/fe72f0532301ec28892ae79a629a293c.jpg"
            }
          ]
        }
      ]
    },
    "metadata": {
      "title": "A Light in the Attic | Books to Scrape - Sandbox",
      "sourceURL": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
      "statusCode": 200,
      "contentType": "text/html",
      "cacheState": "miss",
      "scrapeId": "9038aecc-72c8-48c7-b426-26d1d13748c2",
      "costUsd": 0.004
    }
  },
  "id": "9038aecc-72c8-48c7-b426-26d1d13748c2",
  "costUsd": 0.004,
  "requestId": "9038aecc-72c8-48c7-b426-26d1d13748c2"
}
```

Price, sale, stock and images belong to a variant. A product with no options has one variant. The fields are:

| Field | What it holds |
| - | - |
| `title`, `brand`, `category`, `description` | Text from the page. `category` is a breadcrumb path when the page has one. |
| `url` | The canonical URL of the product page. |
| `variants` | One entry per color, size or other option. |
| `variants[].id`, `sku`, `title` | Identifiers and the variant's name. |
| `variants[].values` | The option values, such as `color`: `Black`. |
| `variants[].price` | `amount`, `currency` (an ISO 4217 code) and `formatted`, the price as the page shows it. |
| `variants[].sale` | `originalPrice`, only when the variant is discounted. |
| `variants[].availability` | `inStock` and `text`, the stock text as the page shows it. |
| `variants[].images` | Each with a `url`, and `alt` text when the page has it. |

A field the page does not state is left out.

## Read a menu

Send `"menu"` the same way. `data.menu` holds:

| Field | What it holds |
| - | - |
| `isMenu` and `confidence` | Whether the page is a menu, and how sure the model is, from 0 to 1. |
| `merchant` | `name` and `type`, such as restaurant or cafe. |
| `currency` | An ISO 4217 code, only when the page states it. |
| `sections` | Each with `name`, `description` and `items`. |
| `sections[].items[]` | `name`, `description`, `price`, `availability`, `dietary`, `calories`, `images`, `url` and `optionGroups`. |
| `optionGroups[]` | A `name` with `options`, each with a `name` and a `price`. |

## Options

| Field | Type | Default | Effect |
| - | - | - | - |
| `formats` | `array` | `["markdown"]` | Add `"product"` for a product page and `"menu"` for a menu. They need no other field. |

## Limits and errors

* When the page is not a product page, `product` is left out of `data` and `data.warning` says why. The same holds for `menu` on a page that is not a menu. The \$3 is not charged.
* The model reads the first 50,000 characters of the page's Markdown.

## Price

$4 per 1,000 pages for each of the two: $1 for the page and $3 for `product` or `menu` when it returns something. Asking for both on one page is $7 per 1,000 pages when both return something.

## Related

* [JSON](https://docs.stophy.dev/scrape/json.md) fills any fields you describe.
* [Pre-built parsers](https://docs.stophy.dev/scrape/prebuilt-parsers) read the data of shopping sites directly.
* [Images](https://docs.stophy.dev/scrape/images.md) lists every image on a page.
* [Change tracking](https://docs.stophy.dev/scrape/change-tracking.md) tells you when a price changes.


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