Отримуйте товари, пов’язуйте їх з інструментами та створюйте безпечні сеанси вбудовування Viewer, Configurator і Customizer.
У прикладах використано серверну допоміжну функцію alterFetch і заголовки authHeaders із посібника з підключення. Зберігайте API-ключі лише на сервері.
Підключення, авторизація та допоміжна функція alterFetch Кінцеві точки товарів повертають дизайни магазину, які можна вбудувати як Viewer, Configurator або Customizer.
Параметр Обов’язково Подробиці nameніШукає за назвою товару/дизайну. customizerніtrue або false. offsetніТипово 0. Має бути >= 0. limitніТипово 9, максимум 50. order_byніid, name або created_at. directionніASC або DESC.
Приклад запиту (fetch)
const params = new URLSearchParams ( {
limit : '20' ,
offset : '0' ,
name : 't-shirt' ,
customizer : 'true' ,
order_by : 'created_at' ,
direction : 'DESC'
} ) ;
const products = await alterFetch ( ` /products? ${ params . toString ( ) } ` ) ;
const product = await alterFetch ( '/products/381' ) ; Приклад відповіді
{
"products" : {
"items" : [
{
"id" : 381 ,
"name" : "Men's T-Shirt" ,
"createdAt" : "2026-01-03T23:55:05.000Z" ,
"productId" : 4 ,
"media" : {
"img" : {
"big" : "https://alterproduct.com/public-api/v1/file/public/products/4/big.png" ,
"medium" : "https://alterproduct.com/public-api/v1/file/public/products/4/medium.png" ,
"small" : "https://alterproduct.com/public-api/v1/file/public/products/4/small.png"
} ,
"mockups" : [ ]
} ,
"storefrontProduct" : {
"id" : 89 ,
"idUserDesign" : 381 ,
"shareAccess" : "public" ,
"isCustomizer" : 1
} ,
"runtimeBindings" : [
{
"id" : 42 ,
"runtimeType" : "customizer" ,
"status" : "active" ,
"externalProductId" : "wc_123"
}
] ,
"embeddable" : {
"viewer" : true ,
"configurator" : true ,
"customizer" : true
}
}
] ,
"total" : 1
}
} Прив’язки середовища виконання поєднують товари зовнішніх магазинів із дизайнами Alter Product і типами інструментів. Їх переважно використовують інтеграції WordPress/WooCommerce та складні серверні системи магазинів.
Параметр Обов’язково Подробиці designIdніID дизайну Alter Product, що належить магазину. externalProductIdтак, для синхронізаціїID зовнішнього товару, наприклад ID товару WooCommerce. runtimeTypeтак, для синхронізаціїviewer, configurator або customizer. statusніdraft, active, inactive, archived або legacy_active. legacyStorefrontProductIdніНеобов’язковий ID застарілого зіставлення. legacyBindingMetaніНеобов’язкові метадані JSON, наприклад manifestHash.
Приклад запиту (fetch)
await alterFetch ( '/runtime-bindings/sync-from-wordpress' , {
method : 'POST' ,
body : JSON . stringify ( {
bindings : [
{
externalProductId : 'wc_123' ,
runtimeType : 'customizer' ,
status : 'active' ,
designId : 381 ,
legacyBindingMeta : {
manifestHash : 'a3b1...'
}
}
]
} )
} ) ;
await alterFetch ( '/runtime-bindings/42' , {
method : 'PATCH' ,
body : JSON . stringify ( {
status : 'inactive'
} )
} ) ;
await alterFetch ( '/runtime-bindings/42/activate' , { method : 'POST' } ) ;
await alterFetch ( '/runtime-bindings/42/deactivate' , { method : 'POST' } ) ; wordpress_local
await alterFetch ( '/runtime-bindings/sync-from-wordpress' , {
method : 'POST' ,
body : JSON . stringify ( {
bindings : [
{
externalProductId : 'wc_123' ,
runtimeType : 'viewer' ,
status : 'active' ,
externalDesign : {
externalDesignKey : 'wp-design-381' ,
productId : 4 ,
title : 'WooCommerce local design' ,
manifestUrl : 'https://yourstore.com/wp-content/uploads/alter/381/manifest.json' ,
assetBaseUrl : 'https://yourstore.com/wp-content/uploads/alter/381/' ,
manifestHash : 'a3b1...' ,
sourceMeta : {
pluginVersion : '1.2.0'
}
}
}
]
} )
} ) ; Приклад відповіді
{
"message" : "runtimeBinding.syncCompleted" ,
"runtimeBindings" : [
{
"id" : 42 ,
"designId" : 381 ,
"externalProductId" : "wc_123" ,
"runtimeType" : "customizer" ,
"status" : "active"
}
]
} Створіть короткостроковий токен вбудовування на сервері, передайте його iframe/середовищу виконання, а потім дозвольте середовищу викликати bootstrap із токеном Bearer.
Параметр Обов’язково Подробиці runtimeBindingIdрекомендованоБажаний ідентифікатор активних прив’язок середовища виконання. toolобов’язково без runtimeBindingIddesigner | viewer | configurator | customizer | model-generator toolIdtool: model-generatorДодатний числовий ID локального проєкту генератора, а не його UUID або ID товару WooCommerce. originтакOrigin, де відображається вбудований інструмент, наприклад https://yourstore.com. designIdодин ідентифікаторID дизайну Alter Product. Не поєднуйте з orderId. orderIdодин ідентифікаторID замовлення Customizer. Дійсний лише для customizer. cartKey + cartModeніКонтекст кошика лише для Customizer. cartMode має значення view або edit.
Приклад запиту (fetch)
const session = await alterFetch ( '/embed/session' , {
method : 'POST' ,
headers : {
'x-alter-client-fingerprint' : '9f1b7a5e4b3c2d1f9f1b7a5e4b3c2d1f'
} ,
body : JSON . stringify ( {
runtimeBindingId : 42 ,
origin : 'https://yourstore.com'
} )
} ) ;
const bootstrapResponse = await fetch ( 'https://alterproduct.com/public-api/v1/runtime/bootstrap' , {
method : 'GET' ,
headers : {
Authorization : ` Bearer ${ session . token } `
}
} ) ;
const bootstrap = await bootstrapResponse . json ( ) ;
console . log ( { session , bootstrap } ) ; Примітки
await alterFetch ( '/embed/session' , {
method : 'POST' ,
body : JSON . stringify ( {
tool : 'customizer' ,
origin : 'https://yourstore.com' ,
orderId : 123
} )
} ) ;
await alterFetch ( '/embed/session' , {
method : 'POST' ,
body : JSON . stringify ( {
tool : 'viewer' ,
origin : 'https://yourstore.com' ,
designId : 381
} )
} ) ; Приклад відповіді
{
"token" : "eyJhbGciOiJIUzI1NiIsImtpZCI6IjEifQ..." ,
"expiresIn" : 900 ,
"kid" : "1" ,
"mode" : "design" ,
"runtimeBindingId" : 42 ,
"runtimeType" : "customizer"
} Runtime bootstrap
{
"runtimeBindingId" : 42 ,
"designId" : 381 ,
"productId" : "wc_123" ,
"runtimeType" : "customizer" ,
"storageMode" : "wordpress_local" ,
"manifestUrl" : "https://yourstore.com/wp-content/uploads/alter/381/manifest.json" ,
"assetBaseUrl" : "https://yourstore.com/wp-content/uploads/alter/381/" ,
"manifestHash" : "a3b1..." ,
"planCapabilities" : {
"viewer" : true ,
"configurator" : true ,
"customizer" : true
} ,
"cartKey" : null ,
"cartMode" : null ,
"orderId" : null
}