🇬🇧 ASDA Example solution JavaScript /suggest + /products

Feeding 4 for £50 at ASDA — the script that settled the bet

This script tests whether feeding four people for a week on £50 is achievable at ASDA. It uses Pepesto's /suggest endpoint to find budget-friendly dinners, then /products to price each ingredient list at asda.com — tallying the total against the target.

Run this yourself

$ PEPESTO_API_KEY=your_key node asda-budget-week-50-pounds.js

Full script: asda-budget-week-50-pounds.js. You'll need an API key to run it — get one here.

Getting started

One API key, one environment variable, same as always.

js
const res = await fetch('https://s.pepesto.com/api/link', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ email: 'sam@example.com' }),
});
const { api_key } = await res.json();
// export PEPESTO_API_KEY=pepesto_live_...

The first call — finding budget recipes with /suggest

The /suggest endpoint searches the Pepesto recipe database without needing a URL. Pass a free-text query and get back structured recipes — complete with ingredients, steps, and a kg_token ready for the product lookup step.

js
const suggestRes = 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: 'cheap family dinners under £10',
    num_to_fetch: 5,
  }),
});
const { recipes } = await suggestRes.json();

The response returns five fully structured recipes. Here's one of them:

json — one recipe from /suggest
{
  "title": "Baked Tortillas with Minced Meat, Vegetables, and Cheese",
  "ingredients": [
    "130g canned corn", "1 red pepper (~110g)", "1 yellow bell pepper (~150g)",
    "400g canned tomatoes", "1 onion (~150g)", "1 bunch parsley",
    "200g cheddar cheese", "700g ground beef", "300g tortillas",
    "sunflower oil", "salt", "black pepper", "chilli powder",
    "smoked paprika", "soy sauce"
  ],
  "nutrition": { "calories": 4287, "protein_grams": 238, "fat_grams": 260 },
  "kg_token": "EjoKOEJha2VkIFRvcnRpbGxhcyB3aXRoIE1pbmNlZCBNZWF0..."
}

Then I hit /products for each recipe at asda.com, picking the cheapest product per ingredient line.

js
async function fetchAsdaProducts(kgToken) {
  const res = 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: [kgToken],
      supermarket_domain: 'asda.com',
    }),
  });
  const data = await res.json();
  return data.items;
}

// Cheapest product per ingredient line
function cheapestCost(items) {
  return items.reduce((total, item) => {
    if (!item.products?.length) return total;
    const prices = item.products.map(p => p.product.price.price).sort((a, b) => a - b);
    return total + prices[0];
  }, 0);
}

// Fetch products for all 5 recipes in parallel
const allItems = await Promise.all(recipes.map(r => fetchAsdaProducts(r.kg_token)));
const grandTotal = allItems.reduce((sum, items) => sum + cheapestCost(items), 0);

console.log(`5 dinners for 4: £${(grandTotal / 100).toFixed(2)}`);

What the data showed

The script returned £43.17 for five dinners at ASDA, using the cheapest available product per ingredient. Note that some ingredients are priced for pack quantities you won't fully use in a single recipe — the smoked paprika being a typical example.

A few observations from the data. ASDA's own-brand ranges are competitive: ASDA Finely Sliced Bavarian Style Ham 120g came in at £2.24 including a live promotion. Canned goods were uniformly low: Island Sun Sweetened Condensed Milk 397g at £1.47, Tropical Sun Cornmeal Fine Polenta 500g at £1.00. Fresh protein was the main budget driver — chicken thighs and beef mince pushed individual meal costs toward £12–14.

Next steps

From a list of priced items, the natural next step is a cart. Build a skus array from the matched products (each with session_token and num_units_to_buy), call /api/session with the supermarket_domain and skus, then pass the returned session_id to /api/checkout to get the basket URL:

json — example /session response
{
  "session_id": "ses_4rQnBwKpLxZm7vTe"
}

Pass the session_id to /checkout to get a pre-filled ASDA basket link. Since ASDA doesn't have a native guest-shareable cart URL, the Pepesto session acts as the share mechanism — you send the link to anyone in the household and they can open it and order.

The result

The main implementation work is formatting the output table — a per-meal line, a grand total, and an over/under budget verdict. The API calls themselves are straightforward.

Running this weekly over a month, results vary by about £4–8 depending on active promotions and which specific recipes the query returns. The £50 budget is achievable most weeks — the main risk is beef mince pricing.

What else you could do?

Three natural extensions. Filter for items currently on promotion — ASDA runs significant rollback pricing that the promo: true flag surfaces directly. Add a "prefer own-brand" sort that deprioritises branded products when a cheaper ASDA own-brand match exists on the same ingredient line. Run the same five meals against Tesco and Morrisons using the same kg_tokens — no re-parsing needed — to find the cheapest store for your specific recipe set.

Links

Ready to build?

Start building budget shopping lists at ASDA

Use /suggest to find budget-friendly recipes and /products to price them at ASDA with a single key.

27supermarkets 13countries 1schema Instant access