React 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 API key and optional configuration.
GlamAR.init(containerId, apiKey, options);
Initialization Payload
Name | Type | Description |
---|---|---|
apiKey | string | Your Access Key |
platform | string | Platform you're targeting (e.g. web) |
category | string | Supports lots of categories |
configuration | ConfigurationOptions | Initialization configuration object |
Following are all the configuration options that can passed under theoptions
object.
Subcategories defined in overview section can be passed in the category
parameter.
ConfigurationOptions
Name | Type | Description |
---|---|---|
global | GlobalOptions | Global options that customize sdk ui and camera options |
skinAnalysis | SkinAnalysisOptions | Options regarding skin anaylysis |
ui | UIOptions | Loader and watermark configuration object |
ar | AROptions | 3D Modelviewer options |
GlobalOptions
Name | Type | Description |
---|---|---|
openLiveOnInit | boolean | Skip landing and go directly to camera |
disableClose | boolean | Hide the close button |
disableBack | boolean | Hide the back button |
Example
GlamAR.init("containerId", "apiKey", {
// other options
configuration: {
global: {
"openLiveOnInit": true,
"disableClose": false,
"disableBack": false
}
// other options
}
});
SkinAnalysisOptions
Name | Type | Description |
---|---|---|
version | string | Skin analysis engine version |
defaultFilter | boolean | Enable default filter at startup |
startScreen | boolean | Show intro screen before scan |
Example
GlamAR.init("containerId", "apiKey", {
// other options
configuration: {
skinAnalysis: {
"version": "GlamGen",
"defaultFilter": true,
"startScreen": true
}
// other options
}
});
UIOptions
Name | Type | Description |
---|---|---|
loader | LoaderOptions | Loader configuration options |
watermark | WatermarkOptions | Watermark configuration options |
LoaderOptions
Name | Type | Description |
---|---|---|
disable | boolean | Disable loader screen |
jsonData | string | Custom Lottie animation JSON URL |
backgroundColor | string | Loader screen background color (HEX or RGB) |
Example
GlamAR.init("containerId", "apiKey", {
// other options
configuration: {
loader: {
"disable": false,
"jsonData": "https://cdn.pixelbin.io/v2/glamar-fynd-835885/original/glamar_assets/loaders/loader_default.json",
"backgroundColor": "#000000"
}
// other options
}
});
WatermarkOptions
Name | Type | Description |
---|---|---|
text | string | Text shown next to watermark |
fontColor | string | Color of watermark text |
logo | string | URL for the watermark logo image |
Example
GlamAR.init("containerId", "apiKey", {
// other options
configuration: {
watermark: {
"text": "Water Mark Text",
"fontColor": "#00ff00",
"logo": "https://cdn.pixelbin.io/v2/glamar-fynd-835885/original/glamar_assets/icons/cxr_logo_w-yDFY_5Mio.svg"
}
// other options
}
});
AROptions
Name | Type | Description |
---|---|---|
disable3DUI | boolean | Hide 3D model viewer UI |
Example
GlamAR.init("containerId", "apiKey", {
// other options
configuration: {
ar: {
"disable3DUI": false
}
// other options
}
});
Basic Example
GlamAR.init("containerId", "apiKey", {
"apiKey": "YOUR_API_KEY",
"platform": "web",
"category": "skinanalysis",
"configuration": {
"global": {
"openLiveOnInit": true
},
"skinAnalysis": {
"version": "GlamGen",
"defaultFilter": true,
"startScreen": true
}
}
});
Advanced Example (with Configuration)
GlamAR.init("containerId", "apiKey", {
"apiKey": "YOUR_API_KEY",
"platform": "web",
"category": "skinanalysis",
"configuration": {
"global": {
"openLiveOnInit": true,
"disableClose": false,
"disableBack": false
},
"skinAnalysis": {
"version": "GlamGen",
"defaultFilter": true,
"startScreen": true
},
"ui": {
"loader": {
"disable": false,
"jsonData": "https://cdn.pixelbin.io/v2/glamar-fynd-835885/original/glamar_assets/loaders/loader_default.json",
"backgroundColor": "#000000"
},
"watermark": {
"text": "Water Mark Text",
"fontColor": "#00ff00",
"logo": "https://cdn.pixelbin.io/v2/glamar-fynd-835885/original/glamar_assets/icons/cxr_logo_w-yDFY_5Mio.svg"
}
},
"ar": {
"disable3DUI": false
}
}
});
Post-Initialization Methods
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. |
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. |
GlamAR.isLoaded();
Returns the status of module loading.
Return Value:true
if loaded, otherwisefalse
Parameters | Description |
---|---|
None | No parameters required. |
GlamAR.open();
Opens the AR widget.
Return Value: None
Parameters | Description |
---|---|
None | No parameters required. |
GlamAR.skinAnalysisChangeCategory(skinCategoryName);
Displays the concern images or filter of the specific category. For Category name, tech name should be used from API response.
Return Value: None
Parameters | Type | Description |
---|---|---|
skinCategoryName | string | A Tech name of specific skin category |
GlamAR.reset();
Removes all the current effects from the canvas.
Return Value: None
Parameters | Description |
---|---|
None | No parameters required. |
GlamAR.close();
Closes canvas and returns to the main widget page.
Return Value: None
Parameters | Description |
---|---|
None | No parameters required. |
GlamAR.snapshot();
Takes a snapshot of the current result window. Result of the screen can be get from photo-loaded event in
base64
formate.
Return Value: none
Parameters | Description |
---|---|
None | No parameters required. |
GlamAR.back();
To simulate back button without using UI
Return Value: None
Parameters | Description |
---|---|
None | No parameters required. |
Events
Event | Payload | Description | Example Usage |
---|---|---|---|
loading | None | Fired when the GlamAR module is initiated and the SDK proceeds with the loading process. |
|
loaded | None | Fired when the GlamAR module is loaded. |
|
opened | None | Fired when the GlamAR module is opened. |
|
closed | None | Fired when the canvas is closed and the user returns to the main widget page. |
|
camera-opened | None | Fired when the camera is opened. |
|
camera-closed | None | Fired when the camera is closed. |
|
camera-failed | None | Fired when the camera fails. This can occur if the user refuses to grant permission or the app is unable to retrieve the video stream normally. |
|
photo-loaded | Image (base64), Status (success/failed) | Fired when a screenshot of the AR effect is successful or fails. |
|
error | Error : Error information | Fired anytime an error occurs. |
|
subscription-invalid | string : Reason why the subscription is invalid | Fired when the subscription is found to be invalid or expired. |
|
skin-analysis | options : type of payload (result , retouch , error , capture ), value : associated data | Fired for skin analysis related events. Use the `options` field to determine the kind of event. |
|