Fetch each product
Look up every GTIN on the page. The calls are independent, so run them in parallel:Pick the cheapest offer
Compare only offers in the same currency and in stock:shops as “from 1 279 kr at Nordic Pet, 3 shops” and saving as “save up to 70 kr”.
Keep it fast
- Cache each product for five minutes; prices don’t change faster than the merchants’ feeds.
- For a large list, render from your own cache and refresh it in the background, rather than calling the API on every page view.
- Prices are decimal strings.
Number()is fine for sorting and display; use a decimal library if you add them up.