Pobieraj produkty, łącz je z narzędziami i twórz bezpieczne sesje osadzania Viewera, Configuratora i Customizera.
Przykłady wykorzystują serwerowy helper alterFetch i nagłówki authHeaders z instrukcji połączenia. Klucze API przechowuj wyłącznie na serwerze.
Połączenie, autoryzacja i helper alterFetch Endpointy produktów zwracają designy storefrontu, które można osadzać jako viewer, configurator albo customizer.
Parametr Wymagany Szczegóły namenieSzuka po nazwie produktu/designu. customizernietrue albo false. offsetnieDomyślnie 0. Musi być >= 0. limitnieDomyślnie 9, maksymalnie 50. order_bynieid, name albo created_at. directionnieASC albo DESC.
Przykładowe zapytanie (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' ) ; Przykładowa odpowiedź
{
"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
}
} Runtime bindings łączą zewnętrzne produkty commerce z designami Alter Product i typami runtime. Używają ich głównie integracje WordPress/WooCommerce oraz zaawansowane backendy storefrontu.
Parametr Wymagany Szczegóły designIdnieID designu Alter Product należącego do storefrontu. externalProductIdtak dla syncZewnętrzne ID produktu, np. ID produktu WooCommerce. runtimeTypetak dla syncviewer, configurator albo customizer. statusniedraft, active, inactive, archived albo legacy_active. legacyStorefrontProductIdnieOpcjonalne ID legacy mappingu. legacyBindingMetanieOpcjonalne metadane JSON, np. manifestHash.
Przykładowe zapytanie (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'
}
}
}
]
} )
} ) ; Przykładowa odpowiedź
{
"message" : "runtimeBinding.syncCompleted" ,
"runtimeBindings" : [
{
"id" : 42 ,
"designId" : 381 ,
"externalProductId" : "wc_123" ,
"runtimeType" : "customizer" ,
"status" : "active"
}
]
} Utwórz krótko żyjący token embed po stronie serwera, przekaż go do iframe/runtime, a następnie runtime pobiera kontekst przez bootstrap z tokenem Bearer.
Parametr Wymagany Szczegóły runtimeBindingIdzalecanyPreferowany identyfikator aktywnego runtime bindingu. toolwymagany bez runtimeBindingIddesigner | viewer | configurator | customizer | model-generator toolIdtool: model-generatorDodatni liczbowy identyfikator lokalnego projektu generatora, nie jego UUID ani ID produktu WooCommerce. origintakOrigin, na którym renderowany jest embed, np. https://yourstore.com. designIdjeden identyfikatorID designu Alter Product. Nie łącz z orderId. orderIdjeden identyfikatorID zamówienia customizera. Działa tylko dla customizera. cartKey + cartModenieKontekst koszyka tylko dla customizera. cartMode to view albo edit.
Przykładowe zapytanie (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 } ) ; Uwagi
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
} )
} ) ; Przykładowa odpowiedź
{
"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
}