This documentation describes how to integrate Miso's client-side SDK for Javascript. This SDK allows you to:

  • Configure and create a client instance
  • Retrieve search and recommendation results using APIs
  • Track user interactions with APIs, with automatically managed context information

The latest version of the Miso client-side SDK for Javascript is 1.4.2 and can be downloaded via npm.

npm badge


npm module

To install the SDK as an npm module, run the following in your project directory:

npm install --save @miso.ai/client-sdk

Script tag

This SDK is also served by jsDelivr. You can include the SDK in your webpage with the following script tag:

<script src="https://cdn.jsdelivr.net/npm/@miso.ai/client-sdk"></script>


Creating a Miso client

If you are using an npm module, create the client instance using the following example:

const MisoClient = require('@miso.ai/client-sdk');
const apiKey = '...';
const miso = new MisoClient(apiKey);

If you are accessing the SDK via script tag, create the client instance using the following example:

var apiKey = '...';
var miso = new MisoClient(apiKey);

If the SDK is loaded using an async script tag, it will be ready in the following callback:

var apiKey = '...';
var misocmd = window.misocmd || (window.misocmd = []);
misocmd.push(function () {
  var miso = new MisoClient(apiKey);

Context Variables

This is a quality-of-life module. You can save shared variables with the context API, so they will be passed into other API calls automatically.

Anonymous IDs

The SDK takes care of anonymous_id automatically using session storage. It will be managed and passed into API calls automatically.

You can also set anonymous_id by yourself:

miso.context.anonymous_id = 'my_anonymous_id';

User ID and hash

Set user_id and user_hash:

miso.context.user_id = 'user_id';
miso.context.user_hash = 'user_hash';

See REST API for more details about user_hash.

Request Options


You can specify a timeout in milliseconds:

try {
  const { products } = await miso.api.recommendation.userToProducts(payload, { timeout: 5000 });
} catch (e) {
  // ...


You can call APIs in bulk mode. API calls in bulk mode from the same event loop will be packed into a single HTTP request to save communication resources:

const [ responseA, responseB ] = await Promise.all([
  miso.api.recommendation.userToProducts(payload, { bulk: true }),
  miso.api.recommendation.userToTrending(payload, { bulk: true })

Be aware of asynchrony. In the following example, the bulk mode will NOT be in effect:

const responseA = await miso.api.recommendation.userToProducts(payload, { bulk: true });
const responseB = await miso.api.recommendation.userToProducts(payload, { bulk: true });
Icon/Activity Icon/Add Icon/API Icon/Arrow/Down Icon/Arrow/Left Icon/Arrow/Right Icon/Arrow/TopRight Icon/Arrow/Up Icon/Bento Icon/Billing Icon/Bin Icon/Book Icon/Bookmark/Default Icon/Bookmark/Filled Icon/Calendar Icon/Caret/Down Icon/Caret/Up Icon/Chavron/DownIcon/Chavron/LeftIcon/Chavron/RightIcon/Chavron/UpIcon/Checknox/CheckedIcon/Checknox/Unchecked Icon/Checklist Icon/Chip Icon/Clipboard / Copied Icon/Clipboard/Default Icon/Clock/Stopwatch Icon/CMD Icon/Data/Catalog Icon/Data/Engine Icon/Data/Group Icon/Data/Interact Icon/Data/Users Icon/Dive Icon/Docs/Key Icon/Dojo Icon/Email Icon/Env/Development Icon/Env/Playground Icon/Env/Prod Icon/Folder Icon/Fullscreen/Collapse Icon/Fullscreen/Expand Icon/Guides/Multiple Icon/Guides/Single Icon/Hashtag Icon/Heart/Outline Icon/Heart/Solid Icon / Cart z Icon / Click Icon / Clock Icon / Data Icon / Doc Icon / EmptyCart z Icon/Social/Facebook Icon / Genome Incognito Icon / Money Icon/Social/ProductHunt Icon / Search Icon/Social/Twitter Icon / User Icon/Info/Error Icon/Info/Info Icon/Info/Question Icon/Info/Warning Icon/Interact/Download Icon/Interact/Edit Icon/Interact/External v2 Icon/Interact/External Icon/Interact/Filter Icon/Interact/Logout Icon/Interact/Options Icon/Interact/Re-order Icon/Interact/Reload Icon/Interact/Remove Icon/Interact/Replace Icon/Interact/Search Icon/Interact/Shuffle Icon/Interact/Undo Icon/Interact/Upload Icon/Interact/Video Icon/Invoice Icon/Loading Icon/Loading Icon/Lock/Locked Icon/Lock/Unlocked Icon/Lock Icon/Mapping Menu Icon/Notification Icon/Overview Icon/Person/Team Icon/Person/User Icon/Plan/Enterprise Icon/Plan/Growth Icon/Plan/Startup Icon/Plan/Trial Icon/Recipe Icon/Rocket Icon/Settings/App Icon/Settings/User Icon/Settings Icon/Shrine Icon/Sidebar/Close Icon/Sidebar/Open Icon/Slideout Icon/Sort/Ascending Icon/Sort/Default Icon/Sort/Descending Icon/Star/Filled Icon/Star/Outlined Stopwatch Icon/Support Icon/Tag Icon/Interact/Thumb/Dislike Icon/Interact/Thumb/Like Icon/Tick Icon/Trend/New Icon/Trend/Trending Icon/Tutorial Icon/Lock/Unlocked Icon/View/Grid Icon/View/List Icon/Watchlist/Add