Get List of Promotions - Fabric
Get List of Promotions
cURL
curl --request GET \
--url https://prod01-apigw.yourcompany.fabric.zone/api-price/promo \
--header 'x-site-context: <x-site-context>'
Python
import requests
url = "https://prod01-apigw.yourcompany.fabric.zone/api-price/promo"
headers = {"x-site-context": "<x-site-context>"}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript
const options = {method: 'GET', headers: {'x-site-context': '<x-site-context>'}};
fetch('https://prod01-apigw.yourcompany.fabric.zone/api-price/promo', 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://prod01-apigw.yourcompany.fabric.zone/api-price/promo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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://prod01-apigw.yourcompany.fabric.zone/api-price/promo"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-site-context", "<x-site-context>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest (Java)
HttpResponse<String> response = Unirest.get("https://prod01-apigw.yourcompany.fabric.zone/api-price/promo")
.header("x-site-context", "<x-site-context>")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://prod01-apigw.yourcompany.fabric.zone/api-price/promo")
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>'
response = http.request(request)
puts response.read_body
Response Codes
- 200: Successfully gets list of all active promotions.
- 400: SKU cannot be empty.
- 500: An internal error occurred. If the issue persists, please contact support@fabric.inc.
Example Response
{
"query": {
"limit": 10,
"offset": 0,
"count": 66
},
"promos": [
{
"_id": "abcdefg1ee7ce20123456789",
"promoId": 100013,
"promoCodes": [],
"promoCount": 0,
"state": "SCHEDULED",
"isImplicit": true,
"title": "CREATE PROMO",
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": true,
"eligiblePriceList": [
10000056
],
"updatedAt": "2019-08-20T14:15:22Z"
}
]
}
{
"code": 400,
"message": "SKU cannot be empty"
}
{
"code": 500,
"message": "An internal error occurred. If the issue persists please contact support@fabric.inc."
}
Headers
- x-site-context: (string) required. The
x-site-context header is a JSON object that contains information about the source you wish to pull from.
Query Parameters
- offset: (number) Number of records you wish to skip before selecting records. Default is
0 if not specified.
- limit: (number) limits the number of records returned by the API. Default is
10 if limit is not specified.
- keyword: (string) Retrieve records by SKU name.