Skip to main content

Web API References

Initialization Method​

To get started, call the GlamAR.init method. This adds the GlamAR SDK into the target container and configures it with the provided Access key and optional configuration.

GlamAR.init(containerId, accessKey, payload);

Initialization Payload

NameTypeDescription
platformstringPlatform you're targeting (e.g. web)
categorystringSupports lots of categories
metaMetaOptionsOptional initialization metadata object

MetaOptions

NameTypeDescription
preloadMLModelsstring[]Downloads the listed ML models during SDK initialization. AR Try-On supports face, hair, hand, and light. Skin Analysis supports face and light.

Following are all the configuration options that can passed under thepayload object.
Subcategories defined in overview section can be passed in the category parameter.

Basic Example

GlamAR.init("containerId", "accessKey", {
"platform": "web",
"meta": {
"preloadMLModels": [
"face",
"hair",
"hand",
"light"
]
}
});

Advanced Example (with Configuration)

GlamAR.init("containerId", "accessKey", {
"platform": "web",
"category": "sunglasses",
"meta": {
"preloadMLModels": [
"face",
"hair",
"hand",
"light"
]
}
});

Sku config​

Our SDK currently processes sku's in two formats:

  • Id : This is an unique id we give to every SKU created with GlamAR console < Product Inventory. You can check the sku-id in the inventory under column SKU ID
  • Config : This is an object that can be created using the exsisting SKU in your inventory.

Any SKU config must contain 4 key item

{
category: "desired-category", // `eyeware`,`jewellery`,`accessories` etc.
subCategory: "desired-subCategory", // `sunglasses`, `necklace`, `earring`
status: "PUBLISHED",
arEffect:{
// Copy this entire object as it contains all the necessary rendering data we need to show the desired SKU as custimized in the console
}
}

You can also add in 'productName' and 'productImage' properties in the object. These will be used in displaying SKU in our SKU selection area at the bottom.

We provide a Model Viewer for viewing your model in 3D. It supports displaying the dimensions of model, if provided to it. These dimensions are shown in 'cm' measurment. To use this feature, you can add a meta tag inside your object. Example:

{
category: "eyeware",
subCategory: "sunglasses",
status: "PUBLISHED",
arEffect:{
// Details
}
meta:{
dimensions: {
length: "length-of-model",
width: "width-of-model",
height: "height-of-model",
},
}
}
ParametersTypeDescription
categorystringeyeware, makeup, jewellery etc.
subCategorystringsunglasses, necklace, earrings etc.
productNamestringName for the product
productImagestringImage URL for the product
arEffectArEffectOptionsObject contains data that is used to render model accurately
metaMetaOptionsObject contains miscellaneous data

ArEffectOptions​

ParametersTypeDescription
transformobjectContains position and rotation settings
envSettingsobjectContains lighting and environment settings
effectAssets2Dstring[]Contains urls of images for SKU rendering
effectAssets3DEffectAssets3DOptionsContains url of 3D file for rendering

EffectAssets3DOptions​

ParametersTypeDescription
idstringAlways send "full"
urlstring

Valid url to the desired asset. Supported extension is .glb and .txt

MetaOptions​

ParametersTypeDescription
dimensionsobjectContains length, width and height properties

Post-Initialization Methods​

applyBySku​

GlamAR.applyBySku(skuId, callback);

Apply one variant using its exact merchant SKU ID from variants[].skuId. This is not the parent product ID or the variant UUID. The SDK does not show a sibling-variant chooser for this call.
Return Value: None

ParametersTypeDescription
SKU IdstringThe exact, case-sensitive merchant SKU ID from variants[].skuId.
callbackfunctionfunction, fires after the Sku is applied

applyByProductId​

GlamAR.applyByProductId(productId, callback);

Pass the parent product's _id to load the product with its authored variant choices. The first variant is selected initially. A product without authored variant options does not show a variant chooser. The optional callback fires on sku-applied.

GlamAR.applyByProductId("54d7bb83-a0bb-4aa4-8066-8752c96fb739");

Use a scalar product UUID, not an array or a JSON-encoded product/variant tuple.

applyByCategory​

GlamAR.applyByCategory(category);

Pass a category (e.g., makeup, eyewear, jewellery), which the SDK will use to fetch all corresponding SKUs from the Console’s product inventory.
Return Value: None

GlamAR.applyByCategory("makeup");

If storefront-specific filtering is required, pass storeFront as an optional second argument.

GlamAR.applyByCategory("makeup", { storeFront: "store_a" });
ParametersTypeDescriptionOptions
categorystringPass any compatible category

makeup, eyewear, jewellery etc.
Check supported categories

options (optional)objectOptional catalog filter object. Currently supports storeFront.{ storeFront: "store_a" }

applyBySubCategory​

GlamAR.applyBySubCategory(subCategory);

Pass a subcategory (e.g., lipstick, sunglasses, necklace), which the SDK will use to fetch all corresponding SKUs from the Console’s product inventory.
Return Value: None

GlamAR.applyBySubCategory("lipstick");

If storefront-specific filtering is required, pass storeFront as an optional second argument.

GlamAR.applyBySubCategory("lipstick", { storeFront: "store_a" });
ParametersTypeDescriptionOptions
subCategorystringPass any compatible subcategory

lipstick, sunglasses, necklace etc.
Check supported subcategories

options (optional)objectOptional catalog filter object. Currently supports storeFront.{ storeFront: "store_a" }

applyMultipleConfigData​

GlamAR.applyMultipleConfigData(skuConfigArray);

Display multiple SKU types at once. The input should be an array of sku configs. Each item can be of diffrent subcategory eg: sunglasses, caps, earrings, etc.
Return Value: None

ParametersTypeDescription
skuConfigArrayobjectAn Array of SKU Configs

Following is an example of above skuConfigArray for applyMultipleConfigData.

const data = [
{
category: "eyewear",
subCategory: "eyeglasses",
status: "PUBLISHED",
arEffect: {
envSettings: {
useDefaultEnvironment: true,
},
effectAssets3D: [
{
id: "full",
url: "VALID-ASSET-URL", // We support .glb files
},
],
},
},
{
category: "accessories",
subCategory: "caps",
status: "PUBLISHED",
productName: "Test cap",
productImage:
"https://cdn.pixelbin.io/v2/dummy-cloudname/original/05-DP1YgvlO2.png",
arEffect: {
envSettings: {
useDefaultEnvironment: true,
},
effectAssets3D: [
{
id: "full",
url: "VALID-ASSET-URL", // We support .glb files
},
],
},
},
{
category: "jewellery",
subCategory: "earring",
status: "PUBLISHED",
productName: "Test earring",
arEffect: {
envSettings: {
useDefaultEnvironment: true,
},
effectAssets3D: [
{
id: "full",
url: "VALID-ASSET-URL", // We support .glb files
},
],
},
meta: {
size: "",
},
},
];
GlamAR.applyMultipleConfigData(data);

Users will see separate tabs for each category type in the SDK UI.

addEventListener​

GlamAR.addEventListener(eventName, handlerFunction);

Adds the listener to the given event name.
Return Value: None

ParametersTypeDescription
eventNamestring

A Name of specific event or "*" To listen to the all the events.

handlerFunctionfunction Your handler function that will listen to callback.

removeEventListener​

GlamAR.removeEventListener(eventName, handlerFunction);

Removes the given listener for the event name.
Return Value: None

ParametersTypeDescription
eventNamestring

A Name of specific event or "*" To remove all the events.

handlerFunctionfunction Your handler function that will listen to callback.

isLoaded​

GlamAR.isLoaded();

Returns the status of module loading.
Return Value: true if loaded, otherwise false

ParametersDescription

None

No parameters required.

reset​

Removes all applied effects when called without arguments. In multi-try-on, pass a subcategory string or an options object/map to remove selected effects while keeping the others.

GlamAR.reset();
GlamAR.reset("blush");
GlamAR.reset({ subCategory: "blush" });
GlamAR.reset({ skuIds: ["sku-1", "sku-2"] });
ParameterTypeDescription
valuestring or objectOptional. A subcategory string is shorthand for the subCategory option.
subCategorystringSubcategory to clear, such as blush.
skuIdsstring[]IDs of applied SKUs to remove. Pass individual IDs as list entries.

If both filters are supplied, a nonempty skuIds list takes precedence over subCategory. Omitting the argument, passing an empty string, or passing options with no nonempty filter clears all effects.

Returns no value.

configChange​

Updates an adjustment for the active try-on. Availability depends on the current product and experience. skuId and subCategory select the makeup opacity target during multi-try-on; they do not scope finger, position, or scale adjustments.

Use configChange(type, value?, skuId?, subCategory?) or pass one object containing type, value, skuId, and subCategory.

GlamAR.configChange("opacity", 0.5);
GlamAR.configChange("fingers", 2);
GlamAR.configChange("horizontal", 0);
GlamAR.configChange("vertical", 0);

// Target makeup opacity during multi-try-on.
GlamAR.configChange("opacity", 0.5, "sku-1");
GlamAR.configChange("opacity", 0.5, undefined, "lipstick");
GlamAR.configChange({ type: "opacity", value: 0.5, subCategory: "lipstick" });

// Select the makeup opacity target without changing its value.
GlamAR.configChange({ type: "opacity", subCategory: "lipstick" });
ParameterTypeDescription
typestringRequired. opacity (also accepted as intensity), fingers, horizontal, vertical, or scale.
valuenumberNumeric adjustment. Supply a value when changing an adjustment. For opacity/intensity, omitting the value selects the target without changing its opacity.
skuIdstringOptional applied makeup SKU ID to target.
subCategorystringOptional applied makeup subcategory to target, such as lipstick or blush.

Pass one target selector per call. With neither selector, the SDK uses its active makeup target. Returns no value.

setViewportMirrored​

GlamAR.setViewportMirrored(state);

Enables or disables mirrored viewport rendering for AR Try-On.
Return Value: None

GlamAR.setViewportMirrored(true); // Enable mirrored viewport
GlamAR.setViewportMirrored(false); // Disable mirrored viewport
ParametersTypeDescriptionOptions
statebooleanControls whether the AR viewport should render in mirrored mode.

true: enable mirror mode
false: disable mirror mode

close​

GlamAR.close();

Closes canvas and returns to the main widget page.
Return Value: None

ParametersDescription

None

No parameters required.

snapshot​

GlamAR.snapshot();

Takes a snapshot of the current result window. Result of the screen can be get from photo-loaded event in base64 format.
Return Value: none

ParametersDescription

None

No parameters required.

comparison​

GlamAR.comparison(state, skus);

Toggles comparison mode in AR widget.
Return Value: None

Pass a state (i.e, open or close) to toggle between UI and with it 2 SKU ids or Skuconfig of same subcategory say sunglasses or necklace. Diffrent subcategory comparision is not supoorted. The first sku will be shown on the left side and the other one on the right side.

ParametersTypeDescriptionOptions
statestringState to show or hide the UI respectivelyopen close
skusstring[] | object[]Provide 2 SKU Ids or 2 SKU json in an array

["skudID1", "skudID2"]
["SkuConfig1", "SkuConfig2"]

GlamAR.comparison("open", ["skudID1", "skudID2"]); // replace skudID1 and skudID2 with two SKU id's
GlamAR.comparison("close"); // When we send close we don't need to send SKUs

setExperience​

GlamAR.setExperience(experience, options);
GlamAR.setExperience(options); // Web / React VTO shorthand

Switches the active SDK experience without reloading the full SDK. Use this to move between AR Try-On and Skin Analysis faster after the GlamAR module is already loaded.
Return Value: None

GlamAR.setExperience("vto", { category: "eyewear" });
GlamAR.setExperience("vto", { subCategory: "lipstick" });

// Apply one exact merchant-SKU variant.
GlamAR.setExperience({ skuId: "merchant-sku" });
GlamAR.setExperience("vto", { skuId: "merchant-sku" });

// Apply a parent product and keep its authored variant choices available.
GlamAR.setExperience({ productId: "54d7bb83-a0bb-4aa4-8066-8752c96fb739" });
GlamAR.setExperience("vto", { productId: "54d7bb83-a0bb-4aa4-8066-8752c96fb739" });

GlamAR.setExperience("skinAnalysis", {
appId: "0732f85d-5768-462e-a50a-174840438a69",
});
ParametersTypeRequiredDescription
experiencestringOnly in the two-argument formExperience to switch to. Valid values are vto and skinAnalysis. The single-object form selects vto.
optionsobjectYesExperience-specific options used to start the selected flow.
options.categorystringOne VTO selector is requiredCategory to load when switching to AR Try-On.
options.subCategorystringOne VTO selector is requiredSubcategory to load when switching to AR Try-On.
options.skuIdstringOne VTO selector is requiredThe exact merchant SKU from variants[].skuId, not a product ID or variant UUID. Applies only that variant, just like applyBySku.
options.productIdstringOne VTO selector is requiredThe parent product's _id. Selects its first variant initially and retains authored variant choices, just like applyByProductId.
options.appIdstringRequired for Skin AnalysisSkin Analysis app ID to load when switching to Skin Analysis.

For AR Try-On, pass one selector in a call: category, subCategory, skuId, or productId. Both VTO call forms have the same selection behavior. The single-object shorthand is for Web and React; native SDKs retain their documented experience/options signatures.

If multiple selectors are supplied, the SDK uses the first nonblank value in this order: category, subCategory, skuId, productId. Category, subcategory and product-ID values are trimmed. Merchant SKU values are preserved exactly, including casing and surrounding whitespace; they must contain a non-whitespace character.

skuId resolves only the exact merchant identifier in variants[].skuId; productId resolves only the parent product _id. Neither selector guesses another identity type or decodes a product/variant tuple. Use applyBySku or applyByProductId when no experience switch is needed.

Listen to experience-changing, experience-changed, and experience-change-failed events to track switch progress and handle failures.

open​

Use open and its mode variants only when you disable or override the SDK's built-in hero screen and implement your own screen or launch buttons. The built-in hero screen already provides buttons to open the SDK, so no open call is needed when using it. After applying a SKU, call the appropriate variant from your custom button handler.

GlamAR.open();

Opens the AR widget.
Return Value: None

ParametersTypeDescriptionOptions
modestringOpens Live-Tryon, Model/Image-tryon and Model ViewermodelViewer imgTryOn
imgURLstringValid image URLAny valid URL
  • No parameters: Start Live VTO

    GlamAR.open();
  • Model Viewer: Start Model Viewer

    GlamAR.open("modelViewer");
  • Image Try-On:

    • Opens the image/model selection screen:
      GlamAR.open("imgTryOn");
    • Opens try-on directly with a specific image:
      GlamAR.open("imgTryOn", "url_of_image");

Switching Views​

  • While in Live or Image mode, calling:

    GlamAR.open("modelViewer");

    will open the model viewer. Calling GlamAR.open() again returns to the selected Try-On type.

  • To switch from Live to Image mode, call:

    GlamAR.back();

    This resets the Try-On session and then call GlamAR.open() with desired parameter

Note: The SKU must already be applied. If not, the SDK will display an error.

Eye PD Measurement Flow​

We provide an integrated supports for eye pupillary distance (PD) scanning. This is activated when viewing any eyeware categories. If user wants to show his own UI and use this service we have function GlamAR.eyePD() for that case.

GlamAR.eyePD("start"); // To launch or restart Eye PD flow
GlamAR.eyePD("close"); // To exit Eye PD and return to active Try-On

Events​

The sku-applied event includes the applied SKU configuration in data. See the platform-specific callback examples there to read the correct payload shape.

Check Events Page for event details.