Skip to main content

Frontend

Workflow

  1. Include the library from our cdn
<script type="text/javascript" async src="https://cdn.visidea.ai/js-api-client/dist/visidea-api-client.min.js"></script>
  1. Instantiate a new object
var visidea = new Visidea.Api('www.mywebsite.com', 'my_public_token');
  1. Call a public method
visidea.item_view(12, 23);

Instance members

item_view(item_id, user_id, callback)

Track the view of an item.

visidea.item_view(item_id: string, user_id: string, callback: function)

Parameters:

  • item_id (string) the id of the item viewed
  • user_id (string) the id of the user
  • callback (function) the callback to be called

item_cart(item_id, user_id, callback)

Track an item added to cart.

visidea.item_cart(item_id: string, user_id: string, callback: function)

Parameters:

  • item_id (string) the id of the item added to cart
  • user_id (string) the id of the user
  • callback (function) the callback to be called

item_purchase(item_id, user_id, callback)

Track the purchase of an item.

visidea.item_purchase(item_id: string, user_id: string, callback: function)

Parameters:

  • item_id (string) the id of the item purchased
  • user_id (string) the id of the user
  • callback (function) the callback to be called

item_favorite(item_id, user_id, callback)

Track an item added to wishlist.

visidea.item_favorite(item_id: string, user_id: string, callback: function)

Parameters:

  • item_id (string) the id of the item added to wishlist
  • user_id (string) the id of the user
  • callback (function) the callback to be called

merge_users(old_user_id, new_user_id, callback)

Merge two users.

visidea.merge_users(old_user_id: string, new_user_id: string, callback: function)

Parameters:

  • old_user_id (string) the id of the old user
  • new_user_id (string) the id of the new user
  • callback (function) the callback to be called

recommend(algo, user_id, item_id, query, n_rec, callback, params)

Recommend items.

visidea.recommend(algo: string, user_id: string, item_id: string, query: array, n_rec: number, callback: function, params: array)

Parameters:

  • algo (string) the algorithm to be used (one of this list: user | item | similarity | pop)
  • user_id (string) the id of the user
  • item_id (string) the id of the item (if algo is item)
  • query (array) the query to pass to the recommendation engine
  • n_rec (number) how many recommendation we ask to be fetched from server
  • callback (function) the callback to be called
  • params (array) array of params to be passed to the callback

visualsearch(img, callback, params)

Visual search.

visidea.visualsearch(img: string, callback: function, params: array)

Parameters:

  • img (string) the image to be searched (base64 encoded)
  • callback (function) the callback to be called
  • params (array) array of params to be passed to the callback

visualrecommend(img, n_rec, detected_class, callback, params)

Visual recommend items.

visidea.visualrecommend(img: string, n_rec: number, detected_class: string, callback: function, params: array)

Parameters:

  • img (string) the image to be searched (base64 encoded)
  • n_rec (number) how many recommendation we ask to be fetched from server
  • detected_class (string) the dected class of the crop returned by the visualsearch method
  • callback (function) the callback to be called
  • params (array) array of params to be passed to the callback

uuidv4()

This function returns an unique uuid (use if your cms don't provide a userid for anonymous users).

visidea.uuidv4()