Get product and price by sku - Fabric

Get product and price by sku

cURL

curl --request GET \
  --url 'https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10' \
  --header 'Authorization: Bearer <token>' \
  --header 'x-site-context: <x-site-context>'

Python

import requests

url = "https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10"

headers = {
    "x-site-context": "<x-site-context>",
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers)

print(response.text)

JavaScript

const options = {
  method: 'GET',
  headers: {'x-site-context': '<x-site-context>', Authorization: 'Bearer <token>'}
};

fetch('https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "x-site-context: <x-site-context>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Go

package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {

url := "https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("x-site-context", "<x-site-context>")
    req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Unirest

HttpResponse<String> response = Unirest.get("https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10")
  .header("x-site-context", "<x-site-context>")
  .header("Authorization", "Bearer <token>")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://live.copilot.fabric.inc/api-offers/get-product/{sku}?limit=10")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body

Response Examples

Successful Response

{
  "id": "60c789cfe6e0910008fdcd19",
  "channel": [
    12,
    13
  ],
  "startDate": "2021-06-14T16:53:56.020Z",
  "endDate": "2021-06-14T16:53:56.020Z",
  "group": [
    "60c7894b25c05d00087e882c"
  ],
  "imageSetOnAttributes": [
    "http://example.com/virpilalphal.jpg"
  ],
  "isDefault": true,
  "isActive": true,
  "isSoftDeleted": false,
  "title": "Oval shaped table",
  "itemFamily": {
    "id": "60c789973af6bf0009c023df",
    "name": "Shoes"
  },
  "sku": "Ovaltable101",
  "description": "Oval shaped table used as home furniture",
  "state": "READY",
  "itemId": 1000000269,
  "images": [
    {
      "id": "5fd7577251a93f0007e48383",
      "order": 0,
      "label": "https://abchome-xpm-images.s3.amazonaws.com/12.01.20+Giving+Tuesday/Homepage/HP_HolidaySix_GI_1.jpg?w=1067",
      "source": [
        {
          "id": "5fd7577251a93f0007e48383",
          "url": "https://abchome-xpm-images.s3.amazonaws.com/12.01.20+Giving+Tuesday/Homepage/HP_HolidaySix_GI_1.jpg?w=1067"
        }
      ]
    }
  ],
  "attributes": [
    {
      "attributeGroupId": "5fd7577251a93f0007e48383",
      "value": "size",
      "isDefault": true,
      "id": 100034567
    }
  ],
  "variants": [
    "VARIANT-01",
    "VARIANT-55"
  ],
  "createdAt": "2021-06-14T16:54:39.461Z",
  "updatedAt": "2021-06-14T16:54:39.461Z",
  "items": [
    {
      "_id": "cfbc28dd-26b8-40e6-9c37-f233c5a2d004"
    }
  ],
  "price": {
    "id": "5e31832ccaf608b232bb4cdrr",
    "isSoftDeleted": true,
    "itemId": 1000000269,
    "offerId": 1074,
    "createdAt": "2020-08-19T10:53:29.918Z",
    "updatedAt": "2020-08-19T10:53:29.918Z",
    "offers": [
      {
        "price": {
          "sale": 0,
          "base": 229,
          "currency": "USD"
        },
        "channel": 12,
        "startDate": "2018-10-19T16:46:45Z",
        "endDate": "2099-12-31T00:00:00Z",
        "kind": 10000001
      }
    ],
    "query": {
      "limit": 10,
      "count": 50,
      "offset": 0
    }
  },
  "priceRange": {
    "min": 35,
    "max": 12000
  },
  "livePrice": [
    {
      "price": {
        "base": 299,
        "sale": 199,
        "cost": 149,
        "currency": "USD"
      },
      "channel": 12,
      "startDate": "2099-12-31T10:51:00.000Z",
      "endDate": "2099-12-31T10:51:00.000Z",
      "kind": {
        "id": "5fe35c6244076c5ff4968917",
        "name": "Clearance",
        "channel": 12,
        "priceKindId": 12
      },
      "offerCode": 128755531,
      "range": {
        "min": 100,
        "max": 300
      }
    }
  ],
  "promoDates": {
    "startDate": "2099-12-31T10:51:00.000Z",
    "endDate": "2099-12-31T10:51:00.000Z"
  }
}

Product Not Found Response

{
  "code": "PRODUCT_NOT_FOUND",
  "message": "Product not found."
}

Internal Server Error Response

{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error."
}

Authorizations

Authorization

Headers