Making your first API call

Qlik's APIs are extremely powerful ways to embed and leverage the Qlik Analytics Engine in your site or web application. In this tutorial, you can learn how to take your first step into using these APIs.

Setup your CSP policy in Qlik Sense SaaS

The first thing you need to do is modify Qlik's CSP policy. By default, the Content Security Policy (CSP) only allows usage of Qlik Sense Enterprise from your own tenant. In order to enable outside sites to communicate with your tenant, you'll need to edit the "content security policy" in Qlik Sense SaaS' management console. In the left pane, select “Content Security Policy”. Click “Add”.

Fill the “Origin” text box with “fiddle.jshell.net” (or whatever the address of your site or web application), and select “frame-ancestors” box under directive.

Get Authenticated

Make sure you are signed in to Qlik Sense SaaS when first accessing. Once the user is signed in, your browser updates the cookie and allows you to stay signed in. This is the simplest way to get authenticated.

APIcall1

Import require.js and qlik-style.css

Create a new fiddle and add resources by clicking the plus button in the left pane.

APIcall2

Add these to your fiddle resources. changing the URL to your tenant's address:

  • https://xxxx.qlikcloud.com/resources/autogenerated/qlik-styles.css
  • https://xxxx.qlikcloud.com/resources/assets/external/requirejs/require.js

Sample Code

Here is a working sample code on jsfiddle. This code connects to your Qlik Sense Cloud tenant and gets the property information of an app:

To get it working on an app in your Qlik Sense tenant, you'll need to change the base URL, web integration ID and app ID. The base URL should be the address of your Qlik Sense SaaS tenant, something like "mytenant.qlikcloud.com" In order to get a web integration ID, you can add it in the management console as described here:

The ID of the application you want to use can be found in the URL when the application is open. For example with this URL:

https://mytenant.qlikcloud.com/sense/app/c13f39a0-417b-41f4-96a6-944e45187704

The app ID is "c13f39a0-417b-41f4-96a6-944e45187704"

Once this is done, you can run the code in JS Fiddle to see some basic information on the application. Now you've successfully made an API call to your Qlik Sense tenant from an external site.