Retrieves Live Page By URL - Fabric
Retrieves Live Page By URL
cURL
curl --request GET \
--url https://cdn.xm.fabric.inc/api/page/live \
--header 'x-site-context: <x-site-context>'
Python
import requests
url = "https://cdn.xm.fabric.inc/api/page/live"
headers = {"x-site-context": "<x-site-context>"}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {method: 'GET', headers: {'x-site-context': '<x-site-context>'}};
fetch('https://cdn.xm.fabric.inc/api/page/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/page/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/page/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))
}
Java
HttpResponse<String> response = Unirest.get("https://cdn.xm.fabric.inc/api/page/live")
.header("x-site-context", "<x-site-context>")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://cdn.xm.fabric.inc/api/page/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
Expected Response
200
{
"status_code": 200,
"message": "Live version: 39 for page: /home.",
"data": {
"page": {
"_id": "6053609551ad48f797a786e8",
"name": "Homepage",
"pageUrl": "/home",
"__v": 0,
"channels": ["12"],
"createdAt": "2021-03-18T14:15:49.410Z",
"isActive": true,
"isArchived": false,
"pageId": 106,
"seoFields": {
"title": "Knowledge Base Homepage",
"description": "Welcome to our Knowledge Base!",
"_id": "60897c9d892fa80008fb8fea",
"metadata": [{
"_id": "60897c9d892fa80008fb8feb",
"name": "canonical",
"content": "https://docs.fabric.inc",
"updatedAt": "2021-04-28T15:17:49.027Z",
"createdAt": "2021-04-28T15:17:49.027Z"
}],
"updatedAt": "2021-04-28T15:17:49.027Z",
"createdAt": "2021-04-28T15:17:49.027Z"
},
"updatedAt": "2021-04-30T18:21:38.022Z",
"pageType": {
"isDefault": false,
"name": "Homepage",
"urlPrefix": "/home"
}
},
"version": [{
"_id": "60802b257900a3000905e4d0",
"isArchived": false,
"channel": [12],
"channels": ["12"],
"status": "SCHEDULED",
"endDate": "2099-12-31T00:00:00.000Z",
"pageId": "6053609551ad48f797a786e8",
"name": "Default v1",
"description": "Default homepage",
"components": [{
"_id": "605ddce3068a620007becbb9",
"id": "Title",
"params": {
"title": "Knowledge Base",
"subtitle": "Explore our products and headless commerce solutions",
"components": [],
"additionalProp1": {}
},
"order": 1,
"additionalProp1": {}
}, {
"_id": "605de5dda877e000083bc851",
"id": "Showcase",
"params": {
"items": [{
"title": "Enterprise commerce",
"blockColor": "blue",
"blockCustomColor": "#e3e5e9",
"linkText": "Learn more",
"linkUrl": "/start/enterprise-commerce",
"components": [],
"additionalProp1": {}
}]
},
"order": 2,
"additionalProp1": {}
}],
"versionId": 39,
"createdAt": "2021-04-21T13:39:49.807Z",
"updatedAt": "2021-04-30T18:21:37.993Z",
"__v": 0,
"startDate": "2021-04-22T19:55:22.791Z"
}]
}
}
Headers
- x-site-context: string, required
- The
x-site-contextheader is a JSON object that contains information about the source you wish to pull from. The mandatoryaccountis the 24 character identifier found in Copilot. Thechannel(Sales channel ID),stage(environment name), anddateattributes can be used to further narrow the scope of your data source.
- The
Example:
"{\"date\": \"2023-01-01T00:00:00.000Z\", \"channel\": 12, \"account\": \"1234abcd5678efgh9ijklmno\",\"stage\":\"production\"}"
Query Parameters
- url: string, required
- The relative page url for which to retrieve the live page version
Response
200: application/json, Successful operation
200 response object
- status_code: integer, The response status code
- message: string, Status message
- data: object, The data object holding the live page and version details.