Aller au contenu
Garanify

Embed with the API

The snippet loads the label and display settings from the API. The page needs no structured data for it.

The API is built and tested. Hosting at api.garanify.com is in preparation; until then it runs locally. Keys are available on request.

Product page

One line, ideally before </body>. The snippet inserts the notice and the label after the buy button.

<script src="https://cdn.garanify.com/garanify.min.js" defer
        data-garanify-key="gfy_pk_4kq8Zt2mWc9x_…"
        data-sku="WCR870"></script>

Cart and fixed places

Placeholders let you choose the place. data-display="nested" shows the small label that opens the full one in a dialog.

<!-- once in the footer -->
<script src="https://cdn.garanify.com/garanify.min.js" defer
        data-garanify-key="gfy_pk_4kq8Zt2mWc9x_…"></script>

<!-- per cart line -->
<div data-gfy="garan" data-sku="WCR870" data-display="nested"></div>
<div data-gfy="garan" data-sku="DF-2290"></div>

<!-- notice at a fixed place -->
<div data-gfy="notice"></div>

Attributes

AttributeMeaning
data-garanify-keyPublishable key. Turns on API mode; the shop ID is part of the key.
data-skuSKU of the product on this page. Makes the page a product page.
data-langauto (default) or a language code like fr. 24 official EU languages.
data-placesproduct, cart, checkout. If not set, the shop setting applies.
data-max-widthWidth of the notice in px. If not set, the shop setting applies.

Behaviour

  • One request per SKU and page, without cookies, with a 3 second timeout. Responses are cached for 5 minutes.
  • If the API is unreachable or the SKU is unknown, the notice still appears; only the label is missing.
  • Reasons are in window.Garanify.config.api.errors. window.Garanify.rescan() checks the page again after changes.
  • The page must be on a domain of the shop. For staging domains, add the domain to the shop.
  • Without data-garanify-key the snippet runs offline as before, with rules in your code, see platforms.

Without JavaScript: HTML from your server

Render the label on your server and send the HTML fragment with your page. The browsers of your visitors then never call the API (see data protection). Cache the response with its ETag.

curl "https://api.garanify.com/v1/shops/shp_4kq8Zt2mWc9x/products/WCR870/garan?lang=de" \
  -H "Authorization: Bearer $GARANIFY_SECRET_KEY"
import { Garanify } from '@garanify/sdk';

const garanify = new Garanify({ apiKey: process.env.GARANIFY_SECRET_KEY });
const svg = await garanify.products.renderGaran('WCR870', {
  lang: 'de'
});
<?php
// composer require garanify/sdk guzzlehttp/guzzle
$factory = new GuzzleHttp\Psr7\HttpFactory();
$garanify = new Garanify\Garanify(getenv('GARANIFY_SECRET_KEY'), ['httpClient' => new GuzzleHttp\Client(), 'requestFactory' => $factory, 'streamFactory' => $factory]);
$svg = $garanify->products->renderGaran('WCR870', [
    'lang' => 'de',
]);
import os, requests

res = requests.get(
    "https://api.garanify.com/v1/shops/shp_4kq8Zt2mWc9x/products/WCR870/garan?lang=de",
    headers={"Authorization": f"Bearer {os.environ['GARANIFY_SECRET_KEY']}"},
    timeout=10,
)
res.raise_for_status()

The notice: GET /v1/render/notice?lang=en&format=html, no key needed.