SDK JS-Client


The Knowledge js-client allows you to call an Inbenta API endpoint quickly and easily with javascript.


All examples shown are set in a Production environment.


There are two ways you can set up the JS Client: when a SDK is already initialized, or standalone.

With a SDK initialized

If a SDK is already initialized, this means that you already have a client that you can use. As a consequence, there is no need to initialize it again. To access the JS-Client, insert the following before the closing <body> tag of your HTML:

var client = sdk.client


Insert the following code in the <head> section of your HTML. If you need compatibility with IE11 browsers, use the version with polyfills:

<script src="<version>/inbenta-km-client.js" integrity="<hash-type>-<hash>"  crossorigin="anonymous"></script>

If you do not need compatibility with IE11 browsers, you can use the version without polyfills:

<script src="<version>/inbenta-km-client-no-polyfills.js" integrity="<hash-type>-<hash>"  crossorigin="anonymous"></script>

Then, insert the following before your closing <body> tag (See full example in Demonstration below):

var client = InbentaKmClient.createFromDomainKey(<your_Domain_key>, <your_API_Key>);


When you set up the SDK for your Inbenta product, you need to specify the version like this:

<script src="<version>/inbenta-km-client.js" integrity="<hash-type>-<hash>" crossorigin="anonymous"></script>

Versions are written in MAJOR.MINOR.PATCH format.


Inbenta strongly recommends that you use a MAJOR.MINOR.PATCH version.


  • If only MAJOR is set, this script will use the highest available MINOR version. <script src=""></script>
  • If MAJOR.MINOR are set, this script will use the highest available PATCH version.
    <script src=""></script>
  • If you specify the full version, only this exact version will be used.
    <script src="" integrity="sha384-549ni4+Y7QvqPcjqufrsbnQALdf0r62sYlmL15ZqIQBkwoWM9NKPEf6uDOBwIXmu" crossorigin="anonymous"></script>

An SRI check is available for this SDK. For more information, see the SDK Subresource Integrity page. Remember that SRI only works with full versions.


  <div id="inbenta">
  <script type="text/javascript">
    var access_token = "<your_access_token>"; //Get it from /auth endpoint with the secret and API Key
    var options = {
    var inbentaKey = "<your_API_Key>";
    var client = InbentaKmClient.createFromAccessToken(<your_access_token>, <your_API_Key>, options);'This is my test query', {}).then( function (response) {
      // Do something with the results


Name Type Default Description
userType integer 0 Defines the profile identifier from the Knowledge instance knowledge base. It will be used in client as x-inbenta-user-type header to make API requests. For more information about this header, see the API Routes.
environment String production Defines source environment from the Knowledge instance knowledge base. It will be used in client as x-inbenta-env header. For more information about this header, see the API docs.


All JS Client methods are described in the following page: JS Client Methods.

Handling Errors

Click here to see a list of API error codes.

// Search example'movies').then(function(response){ {
    console.log(`Result(${}): ${result.title}`);
}).catch(function (error) {
    if (error.response) {
      // The request was made and the server responded with a status code
      // that falls out of the range of 2xx
    } else if (error.request) {
      // The request was made but no response was received
      // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
      // http.ClientRequest in node.js
    } else {
      // Something happened in setting up the request that triggered an Error
      console.log('Error', error.message);

Libraries and Browser Support

The JavaScript SDK depends on:

  • vue 2.5.17
  • axios 0.26.1
  • CORS

The following browsers are supported:

  • IE 11+ (only in the Knowledge SDK version with polyfills)
  • Last version of self-updating browsers:
    • Chrome
    • Firefox
    • Safari
    • Edge