🇧🇬 eBag Example solution JavaScript /parse + /products

eBag vs Bulmag: Compare Prices Across Bulgaria's Two Online Grocery Stores

This compares prices between Bulgaria's two main online grocery stores — eBag and Bulmag — by running the same ingredient list through Pepesto's /products endpoint for both domains. The output is an item-by-item price comparison table showing which store is cheaper per ingredient.

Run this yourself

$ PEPESTO_API_KEY=your_key node ebag-vs-bulmag-bg-price-comparison.js

Full script: ebag-vs-bulmag-bg-price-comparison.js. You'll need an API key to run it — get one here.

Getting started

bash
export PEPESTO_API_KEY=pep_sk_your_key_here
node ebag-vs-bulmag-bg-price-comparison.js

The first call

Parse the recipe once, get a kg_token, then fire both product requests in parallel with Promise.all. No waiting for one to finish before starting the other.

js
// Step 1: parse the recipe
const { recipe } = 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: 'https://recepti.gotvach.bg/r-musaka-s-kartofeni-pagoni',
    locale: 'bg-BG',
  }),
}).then(r => r.json());

// Step 2: match to both stores in parallel
const [ebagData, bulmagData] = await Promise.all([
  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: [recipe.kg_token], supermarket_domain: 'ebag.bg' }),
  }).then(r => r.json()),

  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: [recipe.kg_token], supermarket_domain: 'bulmag.org' }),
  }).then(r => r.json()),
]);
json — eBag products response (excerpt)
{
  "items": [
    {
      "item_name": "кайма",
      "products": [
        {
          "product": {
            "product_name": "Адана Кебап от Агнешко и Телешко Месо",
            "price": { "price": 1299 },
            "quantity": { "grams": 300 },
            "tags": []
          },
          "session_token": "st_ebag_abc123",
          "num_units_to_buy": 1
        }
      ]
    },
    {
      "item_name": "агнешки котлети",
      "products": [
        {
          "product": {
            "product_name": "Агнешки Френч Рак Meat (R)evolution",
            "price": { "price": 1099, "promotion": { "promo": true, "promo_percentage": 10 } },
            "quantity": { "grams": 300 },
            "tags": []
          },
          "session_token": "st_ebag_def456",
          "num_units_to_buy": 1
        }
      ]
    }
  ],
  "currency": "BGN",
}
json — Bulmag products response (excerpt)
{
  "items": [
    {
      "item_name": "кайма",
      "products": [
        {
          "product": {
            "product_name": "Агнешка плешка България",
            "price": { "price": 1449, "promotion": { "promo": true, "promo_percentage": 12 } },
            "quantity": { "grams": 1000 },
            "tags": []
          },
          "session_token": "st_bulmag_ghi789",
          "num_units_to_buy": 1
        }
      ]
    },
    {
      "item_name": "мляко",
      "products": [
        {
          "product": {
            "product_name": "Ацидофилно мляко Нарине 3 2% 400 гр.",
            "price": { "price": 77, "promotion": { "promo": true, "promo_percentage": 11 } },
            "quantity": { "grams": 400 },
            "tags": []
          },
          "session_token": "st_bulmag_jkl012",
          "num_units_to_buy": 1
        }
      ]
    }
  ],
  "currency": "BGN",
}

What the data showed

The comparison doesn't produce a clear overall winner. eBag wins on fresh meat cuts, where per-kg prices are lower. Bulmag wins on dairy: the Narine Acidophilus Milk at 0.77 EUR for 400g is considerably cheaper than the nearest eBag equivalent.

Both stores return real Bulgarian product names in Cyrillic via product_name. The API preserves these exactly as they appear on the sites: "Агнешки Френч Рак Meat (R)evolution" from eBag, "Агнешка плешка България" from Bulmag. The names are different products, not the same product at different prices — which is an important distinction. You're comparing what the API considers the best match at each store, not a like-for-like identical SKU.

The price.promotion object surfaced active discounts at both stores. eBag had the Lamb French rack on 10% off; Bulmag had Bulgarian lamb shoulder on 12% off and acidophilus milk on 11% off.

Next steps

The script prints a winner per line item and a total basket verdict. The next logical step is to offer a split basket: buy item A from eBag (cheaper there), buy item B from Bulmag (cheaper there). That's a more complex UX but the Pepesto /api/session endpoint handles it — one session per store.

json — session response
{
  "session_id": "ses_ebag_jkl012",
  "redirect_url": "https://app.pepesto.com/session/ses_ebag_jkl012",
  "items_count": 9,
  "total_price_cents": 2847
}

The result

For a musaka, eBag won the overall basket by a small margin. But Bulmag won on dairy and was more competitive on Bulgarian-origin lamb. If you're cooking traditional Bulgarian food and prioritising Bulgarian-origin ingredients, Bulmag's catalogue is better suited. If you want broader selection and generally lower meat prices, eBag has the edge.

The Promise.all approach means both store queries run simultaneously — the total API time is roughly the same as a single call, making cross-store comparison essentially free on latency.

What else you could do?

Implement the split basket: it routes each ingredient to the cheaper store, creates two /session calls in parallel, and prints both redirect URLs alongside the saving vs. a single-store shop. To go even further: track the comparison weekly and surface whether one store consistently wins certain categories over time. When Pepesto adds a third Bulgarian store, the same script extends to a three-way comparison with a single domain change.

Links

Ready to build?

Start comparing Bulgarian grocery prices

Pull live eBag and Bulmag catalogs and compare prices on any recipe — ingredient by ingredient.

27supermarkets 13countries 1schema Instant access