<script type="text/javascript" src="https://cdnw.slycecloud.com/websdk/1.2.0/slyce.ui.sdk.js"></script>
<link rel="stylesheet" href="https://cdnw.slycecloud.com/websdk/1.2.0/slyce.sdk.css">
var sdk = new window.slyceSDK();
For using the Web SDK as AMD or CommonJS2 module, the SDK has to be downloaded and used as a normal module, add it to the local project and use it as normal module.
js - https://cdnw.slycecloud.com/websdk/1.2.0/slyce.ui.sdk.js
css - https://cdnw.slycecloud.com/websdk/1.2.0/slyce.sdk.css
Example code -
var slyceSDK = require('./slycesdk/slyce.sdk');
var sdk = new slyceSDK();
For debug purposes
var sdk = new slyceSDK('staging');
Envs:
- production - default value, all production servers
- staging - stagingenvironment
- dev - development environment
call to server uid endpoint and init providers. resolving the list of services allowed.
- clientId - unified id
Method return native promise object
- on resolve - object with result information like this
{ recognition : false, similar: false }
- on reject - Error object with text message
var id = 'superidididid';
sdk.init(id).then(function(data) {
console.log(data); // { recognition : true, similar: true }
}, function(error) {
console.log(error); // Error('Incorrect client id')
});
call to exact match as well as 3D search (sent simultaneously)
- url - image url
- callbackProgress - function which called when status changed
Method return native promise object
- on resolve - return array with products list from fastest provider
- on reject - Error object with text message
var url = 'http://imageurl.com/image.jpg';
sdk.recognitionByUrl(url, function(data) {
console.log(data); // progress event, {"code":8000,"message":"Processing started","progress":20,"token":"d1fL0USvp_ZotmfhmH4Vcw"}
}).then(function(data) {
console.log(data); // success, product list, [{"itemId":"0024984171","productDescription":"Popover fit, Drawstring hood, Long sleeves, Front kangaroo pocket","productImageURL":"https://pics.ae.com/is/image/aeo/0195_9585_604_f?$pdp-main_small$","productImages":["https://pics.ae.com/is/image/aeo/0195_9585_604_f?$pdp-main_small$"],"productName":"AEO Men's Baja Hooded Sweater (Deep Burgundy)","productPrice":"69.95","productURL":""}]
}, function(data) {
console.log(data); // Error('Image not found')
});
Rotate, resize and upload image to amazon s3 and then run recognitionByUrl method
- file - File, received by
- canvas - canvas DOM element. If you do not need rotate and resize use null
- callbackProgress - function which called when status changed
Same with recognitionByUrl
$('input[type="file"]').on('change', function(e) {
sdk.recognitionByFile(e.target.files[0], document.getElementById('canvas'), function(data) { }).then(function(data) {}, function(data) {});
})
Call to Find Similar service
- keyword - file url or product pid
Native promise object
- on resolve - return array with products list from the Find Similar
- on reject - Error object with text message
sdk.similar(url).then(function(data) {
console.log(data); // [{},{}]
}, function(data) {
console.log(data); // Error('Products not found')
});
Call to Find Similar service
- pid - product pid
- url - file url
Native promise object
- on resolve - return array with products list from Find Similar
- on reject - Error object with text message
sdk.getSimilar(pid, url).then(function(data) {
console.log(data); // [{},{}]
}, function(data) {
console.log(data); // Error('Products not found')
});
Close ui view
Call to statistic service
- eventName - name of event
- params - object of properties
Native promise object
- on resolve - return array with products list from Find Similar service
- on reject - Error object with text message
sdk.track('modalOpen',{ product: 4832 }).then(function(data) {
console.log('success');
}, function(data) {
console.log('error');
});