To run the example project, clone the repo, and run pod install
from the Example directory first.
Syte is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Syte', :git => 'https://github.com/syte-ai/iOS-SDK.git'
Also, it is SwiftPM supportable. Add package to project with Xcode:
https://github.com/syte-ai/iOS-SDK.git
In order to use this SDK, please contact Syte for your account ID and signature.
To start using the Syte SDK, instantiate the SyteConfiguration object and pass your API credentials to its constructor. Your credentials can be found in Syte’s Platform - Settings - API Keys. Then use the created instance to set the locale.
let configuration = SyteConfiguration(accountId: <account_id>, signature: <api_signature>)
configuration.locale = <locale>
Then you'll need to initialize Syte class passing the configuration instance :
var syte: Syte? = Syte(configuration: configuration)
API used: https://cdn.syteapi.com/accounts/[account_id]
To retrieve the instance of SytePlatformSettings use the syte.getSytePlatformSettings() method.
For get recent searches:
syte.getRecentTextSearches()
For set viewed product:
syte.addViewedProduct(sku: <String>)
Get all viewed items:
syte.getViewedProducts()
Object detection ("bounds") and a similarity search ("Items") per object detected in the image. Search can be performed with an image or image URL.
To use the image Search functionality do the following:
- Create dedicated class instance and pass the required data.
For Url image search:
let imageSearchRequestData = UrlImageSearch(imageUrl: <image url>, productType: <SyteProductType>)
For image search:
let imageSearchRequestData = ImageSearch(image: <UIImage>)
- Retrieve bounds:
For Url image search:
syte.getBoundsForImageUrl(requestData: <UrlImageSearch>) { [weak self] result in
// Handle response, result type is SyteResult<BoundsResult>
}
For image search:
syte.getBoundsForImage(requestData: <ImageSearch>) { [weak self] result in
// Handle response, result type is SyteResult<BoundsResult>
}
- Retrieve Items for a bound:
syte.getItemsForBound(bound: Bound, cropCoordinates: CropCoordinates) { result in
// Handle response
}
You can pass CropCoordinates instance instead of nil here to enable the crop functionality. Example:
let coordinates = CropCoordinates(x1: 0.2, y1: 0.2, x2: 0.8, y2: 0.8) // The coordinates should be relative ranging from 0.0 to 1.0
syte.getItemsForBound(bound: <Bound>, cropCoordinates: coordinates) { result in
// Handle response, result type is SyteResult<ItemsResult>
}
NOTE Items for the first bound will be retrieved by default. Use
urlImageSearch.retrieveOffersForTheFirstBound = false
or
imageSearch.retrieveOffersForTheFirstBound = false
to disable this behaviour. To get the items for the first bound use the
BoundsResult.firstBoundItemsResult
variable.
To use the "Recommendations" functionality, do the following:
- Use Syte class instance to get results for different features:
getSimilarProducts(similarProducts: SimilarProducts, completion: @escaping (SyteResult<SimilarProductsResult>) -> Void)
getShopTheLook(shopTheLook: ShopTheLook, completion: @escaping (SyteResult<ShopTheLookResult>) -> Void)
getPersonalization(personalization: Personalization, completion: @escaping (SyteResult<PersonalizationResult>) -> Void)
NOTE: You must add at least one product ID to use the "Personalization" functionality. To do this use the
Syte.addViewedProduct(String)
method.
Enabling the personalized ranking will attach the list of viewed products to the requests. To add a product to the list of viewed ones use the
Syte.addViewedProduct(String)
method. To enable this functionality use the
personalizedRanking = true
variable. It is supported in the following classes:
UrlImageSearch, ImageSearch, ShopTheLook, SimilarProducts
Personalized ranking is disabled by default.
The SDK can be used to fire various events to Syte. Example:
syte.fireEvent(EventCheckoutStart())
The SDK can be used for the Text Search functionality.
There are 3 main features:
- Popular Searches. Will retrieve the list of the most popular searches.
syte.getPopularSearches(lang: String, completion: @escaping (SyteResult<[String]>) -> Void)
- Text search. Will retrieve the results for the specified query.
syte.getTextSearch(textSearch: TextSearch, completion: @escaping (SyteResult<TextSearchResult>) -> Void)
To retrieve a list of recent text searches use syte.getRecentTextSearches() method.
- Auto-complete. Text auto-completion functionality.
syte.getAutoCompleteForTextSearch("query", "en_US") { [weak self] result in
// Handle response, result type is SyteResult<AutoCompleteResult>
}
To retrieve the Syte Platform Settings use:
syte.getPlatformSettings(completion: @escaping (SyteResult<SytePlatformSettings>) -> Void)
Artur Tarasenko, [email protected]
Syte is available under the MIT license. See the LICENSE file for more info.