> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aggrefine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Look up a product

> Build a "where to buy" box for one product, cheapest shop first.

Say you review a dog food on your site and want to list the shops that sell it, cheapest first,
each linking through your own tracking link.

<Steps>
  <Step title="Look up the product by its barcode">
    Use the GTIN (EAN/UPC) printed on the package. Shorter codes work too; they are zero-padded to 14 digits.

    ```bash theme={null}
    curl https://api.aggrefine.com/v0/channels/$CHANNEL_ID/products/07318690000016 \
      -H "Authorization: Bearer $AGGREFINE_API_KEY"
    ```

    ```json theme={null}
    {
      "gtin": "07318690000016",
      "title": "Northpaw Adult Chicken, 12 kg",
      "brand": "Northpaw",
      "images": [{ "url": "https://…" }],
      "offers": [
        { "merchant": { "name": "Happy Hound" }, "network": "addrevenue", "price": "1349.00", "currency": "SEK",
          "availability": "in_stock", "affiliate_url": "https://…" },
        { "merchant": { "name": "Nordic Pet" }, "network": "impact", "price": "1279.00", "old_price": "1399.00",
          "currency": "SEK", "availability": "in_stock", "affiliate_url": "https://…" }
      ]
    }
    ```

    A `404` means no shop your channel is approved for sells it: hide the box.
  </Step>

  <Step title="Sort the offers by price">
    Offers come in no particular order. Keep the ones in stock and sort by price:

    ```js theme={null}
    const res = await fetch(
      `https://api.aggrefine.com/v0/channels/${channelId}/products/${gtin}`,
      { headers: { Authorization: `Bearer ${process.env.AGGREFINE_API_KEY}` } },
    );
    if (res.status === 404) return [];
    const product = await res.json();

    const whereToBuy = product.offers
      .filter((o) => o.availability === "in_stock" && o.currency === "SEK")
      .sort((a, b) => Number(a.price) - Number(b.price))
      .map((o) => ({ shop: o.merchant.name, price: o.price, link: o.affiliate_url }));
    ```
  </Step>

  <Step title="Render the links">
    Render each row with `link` as the `href`. A click goes through your network account, so the
    commission is yours.
  </Step>
</Steps>

<Tip>
  Call the API from your server, not the browser, so the key stays secret. Responses can be cached
  for five minutes.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.