๐Ÿ‡ง๐Ÿ‡ช Delhaize Example solution JavaScript /suggest + /products

Plan a Keto Week at Delhaize โ€” Seven Dinners, One Script

This builds a keto dinner plan for the week by using Pepesto's /suggest endpoint to find low-carb recipes, then pricing each at Delhaize via /products. The output is a per-meal shopping list with estimated cost and any substituted items flagged.

Run this yourself

$ PEPESTO_API_KEY=your_key node delhaize-keto-week-meal-plan.js

Full script: delhaize-keto-week-meal-plan.js. You'll need an API key to run it โ€” get one here.

Getting started

If you have already checked out the GitHub repository:

bash
export PEPESTO_API_KEY=your_key_here
node delhaize-keto-week-meal-plan.js

The first call โ€” finding seven keto dinners

The /suggest endpoint accepts a free-text query. Put your dietary constraints directly in the query string โ€” the response is a list of recipes, each with a kg_token encoding the entire ingredient graph.

js
const res = await fetch('https://s.pepesto.com/api/suggest', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.PEPESTO_API_KEY}`,
  },
  body: JSON.stringify({
    query: 'Find me a keto dinner low on carb and high on protein',
    num_to_fetch: 7,
  }),
});
const { recipes } = await res.json();

The response returns seven recipes with titles, ingredient lists, nutrition data, and a kg_token per recipe:

json โ€” /suggest response (excerpt)
{
  "recipes": [
    {
      "title": "Greek-style baked fish with tomatoes and cheese",
      "ingredients": [
        "2 tomatoes (~350g)",
        "3 garlic cloves",
        "15g spring onions",
        "parsley",
        "150g parmesan cheese",
        "200ml sour cream",
        "700g fish fillets",
        "salt",
        "black pepper"
      ],
      "nutrition": {
        "calories": 1883,
        "carbohydrates_grams": 25,
        "protein_grams": 190,
        "fat_grams": 91
      },
      "kg_token": "EjEKL0dyZWVrLXN0eWxlIGJh..."
    },
    {
      "title": "Baked salmon with cream cheese crust",
      "ingredients": [
        "600g salmon fillets",
        "150g cream cheese",
        "2 tbsp lemon juice",
        "fresh dill",
        "2 garlic cloves",
        "black pepper",
        "salt"
      ],
      "nutrition": {
        "calories": 1540,
        "carbohydrates_grams": 8,
        "protein_grams": 142,
        "fat_grams": 98
      },
      "kg_token": "EjIKMEJha2Vk..."
    }
  ]
}

The second call โ€” resolving ingredients to Delhaize products

I take all seven kg_token values and pass them in a single /products call with supermarket_domain: "delhaize.be". The API returns the best-matching Delhaize SKU for every ingredient across all seven recipes.

js
const kgTokens = recipes.map(r => r.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: 'delhaize.be',
  }),
});
const { items } = await productsRes.json();
json โ€” /products response (excerpt)
{
  "items": [
    {
      "item_name": "Fish fillets",
      "products": [
        {
          "product": {
            "product_name": "Delhaize MSC Cod Fillets",
            "quantity": { "grams": 400 },
            "price": { "price": 699, "promotion": { "promo": true } }
          },
          "session_token": "eyJwcm9kdWN0...",
          "num_units_to_buy": 2
        }
      ]
    },
    {
      "item_name": "Parmesan cheese",
      "products": [
        {
          "product": {
            "product_name": "Grana Padano Delhaize 200g",
            "quantity": { "grams": 200 },
            "price": { "price": 389, "promotion": {} }
          },
          "session_token": "eyJwcm9kdWN0...",
          "num_units_to_buy": 1
        }
      ]
    },
    {
      "item_name": "Gouda cheese",
      "products": [
        {
          "product": {
            "product_name": "Delhaize Gouda | Cheese cubes | Young",
            "quantity": { "grams": 120 },
            "price": { "price": 229, "promotion": {} },
            "substitution": true
          },
          "session_token": "eyJwcm9kdWN0...",
          "num_units_to_buy": 1
        }
      ]
    }
  ]
}

What the data showed

The full week of seven dinners came to 47 unique Delhaize line items. Three things are worth noting. First, the API flagged two items as substitutions โ€” it couldn't find an exact match for "sour cream" and returned Delhaize Crรจme Fraรฎche instead. That's close enough for keto, but the flag is useful to know.

Second, seven items were on promotion that week, including the Delhaize MSC Cod Fillets and Delhaize Serrano ham rolls with cream cheese. The promo: true flag is directly in the response, so it's trivial to surface those.

Third, the ingredient de-duplication is excellent. Three recipes called for garlic; the API consolidated them into one line item with num_units_to_buy: 2 rather than listing garlic three times.

The result

A weekly meal plan is now a three-second script. Run it Friday evening, review the list, and place the Delhaize order. The session tokens from the /products response go straight into /api/session to create a checkout link.

What else you could do?

Add a budget cap: if the week's total exceeds โ‚ฌ80, swap the most expensive recipe for a cheaper one and re-run /products. Add a cache so recurring ingredients (olive oil, salt, garlic) are only re-checked when the price changes. Add a weekly HTML email summary to make the whole workflow fully automated.

Links

Ready to build?

Start building keto shopping lists at Delhaize

Use /suggest to generate keto recipes and /products to price them at Delhaize โ€” in two API calls.

27supermarkets 13countries 1schema Instant access