Overview

What is Buy Links

The Build.com Buy Links program dynamically integrates direct purchase links into your online catalog.

These links will direct the customer to a brand-focused retail product page, enabling them to purchase the product immediately.

How does Buy Links work

There are 2 different ways to use this app:

  1. Load script on your web page. We recommend this method for most cases. Skip to technical docs -->
  2. Call API directly. Ideal for more custom implementations. Skip to technical docs -->

Load Script

The Buy Links script renders a customizable Buy Online button by looking up the product SKU in our database and returning a link.

Buy Links requires only a one-time setup, since the links are generated dynamically based on your HTML.

Here are the details:
  1. Your catalog page will have a buylinks HTML tag where you want the button injected. The buylinks tag contains the product SKU.
  2. Our script loads on your site, identifies that HTML tag, and grabs the SKU.
  3. The script makes a live call to our database, which returns the URL where that product lives.
  4. The script then uses that URL to generate the HTML button within the buylinks tag on your page.

In cases where we can't find the product in our database, or the product is out of stock, the button will simply not appear. This makes the Buy Links program simple to utilize with no time-consuming updates.

Ok, I'm ready to dive in! -->

Call API

Calling the API directly gives you just the raw product data, and doesn't render any buttons for you.
  1. You will make an HTTP request to our Buylinks API endpoint, passing SKU directly as a parameter. No need for changes to your HTML.
  2. The API will return data about the product in a json format.
  3. You can use that data to display a custom button, show stock count, and more.
Let's do this API thing! -->

Why use Buy Links

Usage

Method 1: Load Script

The script injects a button containing the link returned from the api.

  1. Load this script in the <head> of your web page:

    <script type="text/javascript" src="https://buylinks.build.com/buttons/script.js"></script>

  2. Insert this HTML where you would like the button injected, replacing the SKU variable with your own:

    <div id="build-buylinks" data-sku="SKU"></div>

After the button is injected, the HTML should look like this:

            
    <div id="build-buylinks" data-sku="57051-PN">
        <a href="https://www.testsite.com/test-product/p2431669?source=testcompany_buylinks_2431669" class="bcom-button">Buy Online</a>
    </div>
            
        

The default buy online button should look like this:

The script does not load in any CSS, but you can add your own custom CSS if you target .bcom-button.

Method 2: Call API

GET /buylinks

The API returns a raw json response that you can use with custom client-side js.

Request URL: https://buylinks.build.com/buylinks/{sku}?hostname={hostname}

Path Parameters

param type description
sku string sku code of product required

Query Parameters

param type description
hostname string hostname of your site, eg. www.youtube.com optional

Response

Type: application/json

Schema
200 object
status integer
data object
link string
productFinishId integer
manufacturer string
manufacturerProductId string
storeId integer
stockCount integer
Example
        
    {
        "status": 200,
        "data": {
            "link": "https://www.testsite.com/test-product/p2431669",
            "productFinishId": 2431669,
            "manufacturer": "Test Company",
            "manufacturerProductId": "57051",
            "storeId": 1,
            "stockCount": 12
        }
    }
        
    

GET /app/api/health

Use the health endpoint to determine if the app is running and to see uptime. You likely won't need to use this endpoint, but it may help rule out problems when troubleshooting.

Request URL: https://buylinks.build.com/app/api/health

Response

Type: application/json

Schema
200 object
status string
uptime float (in seconds)
Example
        
    {
        "status": "UP",
        "uptime": 19815.993
    }