Planning a week of organic Farmy dinners without browsing the store
This builds a week of organic dinner recipes using Pepesto's /suggest endpoint, then prices each recipe at Farmy.ch via /products. The script prioritises products tagged bio in the response, giving you a fully organic shopping list with Farmy prices.
Run this yourself
$ PEPESTO_API_KEY=your_key node farmy-organic-basket-builder.jsFull script: farmy-organic-basket-builder.js. You'll need an API key to run it — get one here.
Getting started
Get your API key to use /suggest and /products:
const res = await fetch('https://s.pepesto.com/api/link', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: 'your@email.com' }),
});
const { api_key } = await res.json();
// export PEPESTO_API_KEY=your_keyStep 1 — /suggest to find five healthy organic dinner recipes
The /suggest endpoint searches the Pepesto recipe database and returns matching recipes with ingredients and a kg_token per recipe. The kg_token is a compact encoding of the ingredient list — you pass it to /products to get matched SKUs at any supermarket.
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: 'healthy organic dinner for two', num_to_fetch: 5 }),
});
const { recipes } = await res.json();
// recipes is an array, each with title, ingredients, steps, and kg_tokenThe response includes full recipe data. Here's what one returned recipe looks like:
{
"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,
"protein_grams": 190,
"fat_grams": 91
},
"kg_token": "EjEKL0dyZWVrLXN0eWxlIGJha2VkIGZpc2ggd2l0aCB0b21hdG9lcyBhbmQgY2hlZXNlS..."
}Step 2 — /products at farmy.ch for all five recipes at once
All five kg_tokens are sent in a single /products call. Pepesto merges the ingredient lists across all recipes and returns a unified items[] array — one entry per ingredient, with multiple Farmy SKUs sorted best-first. Bio products carry a bio tag in the tags[] array.
const kgTokens = recipes.map(r => r.kg_token);
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: kgTokens,
supermarket_domain: 'farmy.ch',
}),
});
const { items, currency } = await res.json();
// items = merged ingredient list across all recipes{
"items": [
{
"item_name": "apples",
"products": [
{
"product": {
"product_name": "Braeburn apples",
"price": { "price": 419 },
"quantity": { "grams": 1000 },
"tags": ["bio", "vegan"],
"product_id": "https://www.farmy.ch/aepfel-braeburn-31353"
},
"session_token": "st_farmy_abc123",
"num_units_to_buy": 1
}
]
},
{
"item_name": "balsamic vinegar",
"products": [
{
"product": {
"product_name": "Balsamic vinegar of Modena IGP 250ml",
"price": { "price": 3205 },
"quantity": { "milliliters": 250 },
"tags": [],
"product_id": "https://www.farmy.ch/aceto-balsamico-di-modena-igp-acetaia-giusti"
},
"session_token": "st_farmy_def456",
"num_units_to_buy": 1
}
]
}
],
"currency": "CHF",
}Preferring bio products
For each ingredient, the API returns multiple Farmy SKUs sorted best-first. To prefer bio, scan item.products[] for the cheapest entry whose tags[] includes "bio" or "organic", falling back to the top pick if none is available:
function pickBestProduct(products) {
const bioProducts = products.filter(p => p.product.tags?.includes('bio') || p.product.tags?.includes('organic'));
const pool = bioProducts.length > 0 ? bioProducts : products;
return pool.sort((a, b) => (a.product.price?.price ?? 0) - (b.product.price?.price ?? 0))[0];
}What the data showed
The five recipes returned by /suggest included a Greek-style baked fish, Cypriot meatballs with sweet potato, a baked tortilla dish, and two others. Every recipe had good Farmy coverage — between 6 and 9 matched SKUs each.
The bio preference logic worked well: Farmy carries Braeburn apples (CHF 4.19/kg) and Granny Smith apples (CHF 4.25/kg) as straightforward vegan-tagged items, and several bio dairy and produce lines appeared in the matched results. The balsamic vinegar of Modena IGP at CHF 32.05 for 250ml was the most expensive single item — which makes sense for a premium Farmy product, though I'd probably swap that for something simpler in practice.
Average estimated cost per dinner came to around CHF 18–24 depending on the recipe. That's higher than a conventional supermarket, but these are fresh, farm-direct, certified organic products — the kind that cost significantly more at a farmers' market.
The result
A two-step API workflow: one call to discover five organic dinner ideas, one call to price them all at Farmy. Total round-trip: under 4 seconds. Run it once a week, pick from the suggestions, and the shopping list is ready.
What else you could do?
Post-filter /suggest results by nutrition — the API returns full macros per recipe, so filtering for high-protein or low-carb is a simple array filter. Pass the session_token values from the chosen products to /session to generate an actual Farmy cart link rather than just a price summary. Add a Migros fallback for items in missing_items[] — Farmy's range is curated, and a few ingredients occasionally return no match.