Retrieves Live Pages - Fabric

Retrieves Live Pages

cURL

curl --request GET \
  --url https://cdn.xm.fabric.inc/api/pages/live \
  --header 'x-site-context: <x-site-context>'

Python

import requests

url = "https://cdn.xm.fabric.inc/api/pages/live"

headers = {"x-site-context": "<x-site-context>"}

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

print(response.text)

JavaScript (Fetch API)

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

fetch('https://cdn.xm.fabric.inc/api/pages/live', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://cdn.xm.fabric.inc/api/pages/live",\
  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://cdn.xm.fabric.inc/api/pages/live"

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://cdn.xm.fabric.inc/api/pages/live")
  .header("x-site-context", "<x-site-context>")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://cdn.xm.fabric.inc/api/pages/live")

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

Success (200)

{
  "status": 200,
  "data": {
    "livePages": [
      {
        "_id": "60788b398fad06000899bdc4",
        "isArchived": false,
        "channel": [12],
        "channels": ["12"],
        "status": "SCHEDULED",
        "endDate": "2099-12-31T00:00:00.000Z",
        "startDate": "2021-04-16T15:05:12.172Z",
        "pageId": "60788b39f59a96c12ce27460",
        "name": "KO v1",
        "components": [
          {
            "_id": "6079db97f395c800086a1ceb",
            "id": "Title",
            "params": {
              "title": "FAQ",
              "subtitle": "Questions you may have around our commerce apps, getting started, security and compliance",
              "components": [],
              "additionalProp1": {}
            },
            "order": 1,
            "additionalProp1": {}
          },
          {
            "_id": "6079db97f395c800086a1cec",
            "id": "PopularQuestions",
            "params": {
              "title": "POPULAR TOPICS",
              "questions": [
                {
                  "title": "Getting started",
                  "body": "Question 1",
                  "linkText": "Click here to view",
                  "linkUrl": "https://fabric.inc/"
                }
              ],
              "components": [],
              "additionalProp1": {}
            },
            "order": 2,
            "additionalProp1": {}
          }
        ],
        "versionId": 36,
        "createdAt": "2021-04-15T18:51:37.475Z",
        "updatedAt": "2021-04-26T16:40:24.212Z",
        "__v": 0,
        "page": {
          "_id": "60788b39f59a96c12ce27460",
          "name": "Popular FAQs",
          "pageUrl": "/faq",
          "__v": 0,
          "channels": ["12"],
          "createdAt": "2021-04-15T18:51:37.416Z",
          "isActive": true,
          "isArchived": false,
          "pageId": 114,
          "typeId": "60788b0bf59a96c12ce27214",
          "updatedAt": "2021-04-26T16:40:24.253Z"
        }
      }
    ]
  },
  "code": "Ok",
  "message": "List of Live Pages",
  "service": "toby",
  "status_code": 200,
  "statusCode": 200
}

No Content (204)

{
  "status_code": 204,
  "message": "There is no live page that exists in the database.",
  "data": {
    "livePages": []
  }
}

Not Found (404)

{
  "status": "PAGE_NOT_FOUND",
  "message": "No Page Entry Found.",
  "statusCode": 404
}

Internal Server Error (500)

{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. If the issue persists please contact support@fabric.inc."
}

Headers

x-site-context

The x-site-context header is a JSON object that contains information about the source you wish to pull from. The mandatory account is the 24 character identifier found in Copilot. The channel (Sales channel ID), stage (environment name), and date attributes can be used to further narrow the scope of your data source.

Example:

{"date": "2023-01-01T00:00:00.000Z", "channel": 12, "account": "1234abcd5678efgh9ijklmno","stage":"production"}

Response Structure