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, apiKey, payload);
Initialization Payload
| Name | Type | Description |
|---|---|---|
| platform | string | Platform you're targeting (e.g. web) |
| category | string | Supports lots of categories |
| meta | MetaOptions | Optional initialization metadata object |
| configuration | ConfigurationOptions | Initialization configuration object |
MetaOptions
| Name | Type | Description |
|---|---|---|
| preloadMLModels | string[] | 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.
ConfigurationOptions
| Name | Type | Description |
|---|---|---|
| skinAnalysis | SkinAnalysisOptions | Options regarding skin anaylysis |
SkinAnalysisOptions
| Name | Type | Description |
|---|---|---|
| appId | string | Skin analysis application ID |
Basic Example
GlamAR.init("containerId", "accessKey", {
"platform": "web",
"category": "skinanalysis",
"meta": {
"preloadMLModels": [
"face",
"light"
]
},
"configuration": {
"skinAnalysis": {
"appId": "your_app_id"
}
}
});
Post-Initialization Methods
addEventListener
GlamAR.addEventListener(eventName, handlerFunction);
Adds the listener to the given event name.
Return Value: None
| Parameters | Type | Description |
|---|---|---|
| eventName | string | A Name of specific event or "*" To listen to the all the events. |
| handlerFunction | function | Your handler function that will listen to callback. |
removeEventListener
GlamAR.removeEventListener(eventName, handlerFunction);
Removes the given listener for the event name.
Return Value: None
| Parameters | Type | Description |
|---|---|---|
| eventName | string | A Name of specific event or "*" To remove all the events. |
| handlerFunction | function | Your handler function that will listen to callback. |
isLoaded
GlamAR.isLoaded();
Returns the status of module loading.
Return Value:trueif loaded, otherwisefalse
| Parameters | Description |
|---|---|
None | No parameters required. |
skinAnalysis
GlamAR.skinAnalysis("start");
Opens the Skin Analysis flow.
Return Value: None
| Parameters | Description | Type | Options |
|---|---|---|---|
| options | Pass start (Required) | string | start |
reset
GlamAR.reset();
Removes all the current effects from the canvas.
Return Value: None
| Parameters | Description |
|---|---|
None | No parameters required. |
close
GlamAR.close();
Closes canvas and returns to the main widget page.
Return Value: None
| Parameters | Description |
|---|---|
None | No parameters required. |
snapshot
GlamAR.snapshot();
After a successfully scan, client can be get a PDF of his scan from
shareevent
Return Value: none
| Parameters | Description |
|---|---|
None | No parameters required. |
back
GlamAR.back();
To simulate back button without using UI
Return Value: None
| Parameters | Description |
|---|---|
| None | No parameters required. |
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",
});
| Parameters | Type | Required | Description |
|---|---|---|---|
| experience | string | Only in the two-argument form | Experience to switch to. Valid values are vto and skinAnalysis. The single-object form selects vto. |
| options | object | Yes | Experience-specific options used to start the selected flow. |
| options.category | string | One VTO selector is required | Category to load when switching to AR Try-On. |
| options.subCategory | string | One VTO selector is required | Subcategory to load when switching to AR Try-On. |
| options.skuId | string | One VTO selector is required | The exact merchant SKU from variants[].skuId, not a product ID or variant UUID. Applies only that variant, just like applyBySku. |
| options.productId | string | One VTO selector is required | The parent product's _id. Selects its first variant initially and retains authored variant choices, just like applyByProductId. |
| options.appId | string | Required for Skin Analysis | Skin 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.
Events
Check Events Page for event details.