🇨🇭 Coop Switzerland Example solution JavaScript /oneshot API

Sunday dinner at Coop CH — one API call, cart pre-filled in under 2 seconds

Here's how to go from a recipe URL to a fully itemised Coop Switzerland cart in a single API call, using Pepesto's /oneshot endpoint. Pass a recipe URL and the coop.ch domain — the response is a redirect URL that opens a pre-filled Coop basket.

Run this yourself

$ PEPESTO_API_KEY=your_key node coop-ch-sunday-dinner-oneshot.js

Full script: coop-ch-sunday-dinner-oneshot.js. You'll need an API key to run it — get one here.

Getting started

Get your Pepesto API key with a single call, then set it in your environment:

js
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_key

The call — /oneshot with a recipe URL

The /oneshot endpoint takes a recipe URL plus a supermarket domain and returns a single redirect URL. Open it in a browser and the Coop cart is already populated with the matched ingredients. You can also pass free-text extras in content_text for things that aren't in the recipe itself.

js
const response = await fetch('https://s.pepesto.com/api/oneshot', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.PEPESTO_API_KEY}`,
  },
  body: JSON.stringify({
    content_urls: [
      'https://www.swissmilk.ch/de/rezepte-kochideen/rezepte/LM201401_83/zuercher-geschnetzeltes/'
    ],
    content_text: 'also add a bottle of dry white wine and a sourdough bread',
    supermarket_domain: 'coop.ch',
  }),
});

The API parses the recipe page — Zürcher Geschnetzeltes, a classic Swiss Sunday dinner of veal strips in cream sauce with Rösti — extracts the ingredient list, matches each one to Coop CH SKUs, and returns:

json
{
  "redirect_url": "https://app.pepesto.com/composed?force=1&req=GigKJmFsc28gYWRk..."
}

That's the entire response. One URL. Open it and you're at Coop's checkout with veal, cream, mushrooms, shallots, white wine, and sourdough bread already in the cart. The Coop products mapped here included items like the Bio Steinofen Aelplerbrot (400g, CHF 3.40) for the bread, and Organic Tessin bread as an alternative — Pepesto picks the best match from Coop's current inventory.

Wrapping it in a function

In a real app you'd call this from a "Shop at Coop" button on your recipe page. The function is three lines once you have the key:

js
async function buildCoopCart(recipeUrl, extraText = '') {
  const body = { content_urls: [recipeUrl], supermarket_domain: 'coop.ch' };
  if (extraText) body.content_text = extraText;

  const res = await fetch('https://s.pepesto.com/api/oneshot', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${process.env.PEPESTO_API_KEY}`,
    },
    body: JSON.stringify(body),
  });

  const { redirect_url } = await res.json();
  return redirect_url;
}

// In a browser:
const url = await buildCoopCart(window.location.href, 'also add mineral water');
window.open(url, '_blank');

What the data showed

The redirect URL was ready in 1.4 seconds. Clicking it opened coop.ch with nine items pre-loaded: kalbfleisch (veal), Rahm (cream), Champignons, Schalotten, a dry white wine, and the sourdough bread I'd added as an extra. Quantities were set automatically based on the recipe's serving size. Two items had alternatives suggested — Coop offers both an own-brand and a premium version for cream, and the API picked the better value option.

The content_text free-text field handles natural-language extras well. "A bottle of dry white wine" matched to a Coop Chasselas 75cl without specifying brand or region — the API infers something contextually appropriate.

The result

A "Shop this recipe at Coop" link that any food blogger in Switzerland can add to their posts. One function, one API key, no Coop developer account required. The full round-trip from recipe URL to clickable cart link takes under two seconds.

What else you could do?

Surface the /parse endpoint before redirecting to Coop — show users the ingredient list so they can remove or swap items before the cart is built. Support multiple supermarkets side by side ("Shop at Coop" / "Shop at Migros") so visitors can choose their preferred store. Persist the last few recipe cart URLs so users can reload a previous basket without re-running the script.

Links

Ready to build?

Start sending shoppers to Coop Switzerland

One API call turns any recipe URL into a pre-filled Coop CH basket — no backend required beyond your API key.

27supermarkets 13countries 1schema Instant access