Flair JavaScript API

Updated: October 2, 2020

This page provides details on how to use the Flair JavaScript API.

Prerequisites

Note: The JavaScript API is available on the Premium Flair plan.

You must enable the JavaScript API by visiting the Flair Settings > JavaScript API and clicking the Enable API button.

Usage

You can use the FlairApp.getProductBadges function to fetch the Flair product badge HTML for a product.

The FlairApp.getProductBadges supports the following options:

  • url - the product url
  • variant - the selected variant ID
  • section - the section name to use to render the Flair product badges; defaults to flair-product-badges

Here is an example of fetching the product badges for a given product, and then logging the results to the console:

1
2
3
4
5
  FlairApp.getProductBadges(
    { "url" : "https://example.myshopify.com/products/example-product" }
  ).then(function(badges) {
    console.log("Flair badges", badges);
  })

If you have any questions about using the Flair JavaScript API, feel free to contact us.