🇮🇪 SuperValu Example solution JavaScript /parse + /session

Irish Dinner Party for Eight — Three Recipes, One Supervalu Basket

This shows how to combine three separate recipe /parse calls — starter, main, dessert — into a single Supervalu Ireland shopping session. Uses Pepesto's /parse, /products, and /session endpoints to go from three recipe URLs to one checkout link.

Run this yourself

$ PEPESTO_API_KEY=your_key node supervalu-dinner-party-three-courses.js

Full script: supervalu-dinner-party-three-courses.js. You'll need an API key to run it — get one here.

Getting started

bash
export PEPESTO_API_KEY=your_key_here
node supervalu-dinner-party-three-courses.js

The first call — parsing three recipes in parallel

Each /parse call takes a recipe URL and returns a structured ingredient list plus a kg_token encoding the whole recipe. Running all three in parallel with Promise.all keeps things fast.

js
const RECIPES = [
  { label: 'Starter',  url: 'https://www.bbcgoodfood.com/recipes/smoked-salmon-prawns-horseradish-cream-lime-vinaigrette' },
  { label: 'Main',     url: 'https://www.bbcgoodfood.com/recipes/slow-cooker-beef-stew' },
  { label: 'Dessert',  url: 'https://www.bbcgoodfood.com/recipes/easy-chocolate-mousse' },
];

const parsed = await Promise.all(RECIPES.map(async ({ label, url }) => {
  const res = await fetch('https://s.pepesto.com/api/parse', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${process.env.PEPESTO_API_KEY}`,
    },
    body: JSON.stringify({ recipe_url: url, locale: 'en-IE' }),
  });
  const data = await res.json();
  return { label, title: data.recipe.title, kg_token: data.recipe.kg_token };
}));
json — /parse response for the starter (excerpt)
{
  "recipe": {
    "title": "Smoked salmon with prawns, horseradish cream & lime vinaigrette",
    "ingredients": [
      "smoked salmon",
      "cooked king prawns",
      "horseradish sauce",
      "sour cream",
      "limes",
      "olive oil",
      "honey",
      "fresh ginger",
      "lettuce"
    ],
    "nutrition": {
      "calories": 310,
      "carbohydrates_grams": 8,
      "protein_grams": 28,
      "fat_grams": 18
    },
    "kg_token": "EjMKMVNtb2tlZCBzYWxtb24..."
  }
}

Products — all three courses in one request

The trick is passing all three kg_token values in a single /products call. The API handles de-duplication and quantity consolidation — dark chocolate appeared in the mousse with a quantity requiring two bars, so it came back as one line item with num_units_to_buy: 2. Beef steak for 8 people resolved to num_units_to_buy: 3.

js
const kgTokens = parsed.map(p => p.kg_token);

const productsRes = await fetch('https://s.pepesto.com/api/products', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.PEPESTO_API_KEY}`,
  },
  body: JSON.stringify({
    recipe_kg_tokens: kgTokens,
    supermarket_domain: 'shop.supervalu.ie',
  }),
});
const { items } = await productsRes.json();
json — /products response (excerpt)
{
  "items": [
    {
      "item_name": "Smoked salmon",
      "products": [
        {
          "product": {
            "product_name": "SuperValu Whiskey Smoked Salmon",
            "quantity": { "grams": 100 },
            "price": { "price": 399, "promotion": { "promo": true } }
          },
          "session_token": "eyJwcm9kdWN0...",
          "num_units_to_buy": 1
        }
      ]
    },
    {
      "item_name": "Beef",
      "products": [
        {
          "product": {
            "product_name": "SuperValu Hereford Irish Fillet Steak",
            "quantity": { "grams": 370 },
            "price": { "price": 1899, "promotion": {} }
          },
          "session_token": "eyJwcm9kdWN0...",
          "num_units_to_buy": 3
        }
      ]
    },
    {
      "item_name": "Dark Chocolate",
      "products": [
        {
          "product": {
            "product_name": "Lindt Excellence 90% Cocoa Dark Chocolate Bar (100 g)",
            "quantity": { "grams": 100 },
            "price": { "price": 485, "promotion": {} }
          },
          "session_token": "eyJwcm9kdWN0...",
          "num_units_to_buy": 2
        }
      ]
    }
  ]
}

Creating the checkout session

Build a skus array — each entry takes the session_token from the top product plus num_units_to_buy — and call /session with the target supermarket_domain. You get back a session_id that you pass to the /checkout endpoint to open a pre-filled Supervalu basket.

js
const skus = items.map(item => ({
  session_token: item.products[0].session_token,
  num_units_to_buy: item.products[0].num_units_to_buy || 1,
}));

const sessionRes = await fetch('https://s.pepesto.com/api/session', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.PEPESTO_API_KEY}`,
  },
  body: JSON.stringify({
    supermarket_domain: 'shop.supervalu.ie',
    skus,
  }),
});
const session = await sessionRes.json();
console.log('Session ID:', session.session_id);
json — /session response
{
  "session_id": "ses_7pQmR2xNkLv9"
}

What the data showed

The three recipes together produced 25 ingredient lines (9 starter + 12 main + 4 dessert). After de-duplication and quantity consolidation, the basket came to 22 items. The total came to €63.30 for a dinner party of eight — under €8 per head for three courses.

Three items were on promotion: smoked salmon, free range eggs, and organic ginger. The API surfaces the promotion object directly on each product, so it's straightforward to highlight deals or sort by them in a UI.

The result

Three recipes parsed in parallel, de-duplicated, and merged into a single Supervalu session. Pass the session_id to /checkout, confirm the basket, and choose a delivery slot.

What else you could do?

Add a "serves N" multiplier so ingredient quantities scale correctly before hitting /products — most recipes are written for 4, so a dinner party of 8 needs quantities doubled. Add logic to flag any item where num_units_to_buy exceeds 3, as that can indicate an over-estimated quantity. Send the redirect URL by email or SMS so it's accessible from a mobile device rather than the terminal.

Links

Ready to build?

Start building Irish dinner party baskets

Parse three course recipes in parallel and build a single SuperValu checkout basket — one session, one link.

27supermarkets 13countries 1schema Instant access