Skip to main content

Get Personalization Data for a Sku Using JavaScript

Introduction

This guide shows you how to retrieve product personalization data for a specific SKU using a simple API request. It is designed for developers with beginner to intermediate experience in JavaScript and API consumption.

By following this tutorial, you'll learn how to make a request to the pz endpoint and receive customization options, including product lines, styles, and choices. This data is used to dynamically display available personalization options on product pages.

Getting started

To retrieve product personalization data, you'll need to make a request to the pz API endpoint. This section will guide you through the prerequisites and the request format.

Prerequisites

Before you begin, ensure that:

  • You have a valid SKU for a product that supports personalization.
  • You can make HTTP requests using JavaScript (fetch), curl, or another API client.

Endpoint Overview

The API follows this format:

code overflow="wrap" fullWidth="false"

GET https://lenox-rb-app-fe68c2643fcd.herokuapp.com/api/v1/products/pz/:sku

:sku (string, required) – The unique identifier of the product.

Example Request

To fetch personalization data for a product with SKU 12345, use the following curl command:

curl -X GET "https://lenox-rb-app-fe68c2643fcd.herokuapp.com/api/v1/products/pz/12345"

Alternatively, using JavaScript:

fetch( "https://lenox-rb-app-fe68c2643fcd.herokuapp.com/api/v1/products/pz/12345")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error fetching data:", error));

Example Response

A successful response returns a JSON object containing pzlines, pzstyles, and pzchoices. Below is a sample response:

{
"pzlines": [
{
"sku_id": "12345",
"style_code": "ABC123",
"style_display_seq": "1",
"style_sku_status": "A"
}
],
"pzstyles": [
{
"style_code": "ABC123",
"line_status": "A",
"line_display_seq": "1",
"choice_type": "Color",
"instruct_text": "Choose a color for customization."
}
],
"pzchoices": [
{
"choice_type": "Color",
"choice_status": "A",
"choice_display_seq": "1",
"choice_value": "Red"
},
{
"choice_type": "Color",
"choice_status": "A",
"choice_display_seq": "2",
"choice_value": "Blue"
}
]
}

Handling Missing SKUs

If the SKU is not found or no personalization data is available, the response will still be a valid JSON object, but all arrays will be empty:

{
"pzlines": [],
"pzstyles": [],
"pzchoices": []
}