Root API

Note: STABLE.
This API is reliable and breaking changes are unlikely.

qlik

The Root API is the external interface to Qlik Sense and is available as the qlik namespace. It provides methods opening apps, get a reference to the current app, set the specific language, and registering callbacks for error handling. The Root API also holds methods for listing available apps and extensions, and registering extensions that you build on the fly (using the Visualization API).

Version history

Introduced 1.0

Getting started

The Root API is available for mashup developers as the qlik namespace.

var config = {
	host: window.location.hostname,
	prefix: prefix,
	port: window.location.port,
	isSecure: window.location.protocol === "https:"
};
require(["js/qlik"], function(qlik) {
	// open the app
	var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config);
}

Version history

Each method and property contain information around when it was introduced, updated, deprecated or removed. A list of all relevant API changes per version release can be found in API version history.

Examples of use

Learn what you can do with the Root API.

Get a list of available apps

You can use the getAppList method to get a list of all apps that are available to you. It opens a WebSocket, gets the app list, and then closes the WebSocket.

var config = {
		host: "myhost.com",
		prefix: "/",
		port: window.location.port,
		isSecure: true
	};
	qlik.getAppList(function(list){
		var str = "";
		list.forEach(function(value) {
			str +=  value.qDocName + '('+ value.qDocId +') ';
		});
		alert(str);
	}, config);

Open an app and access the App API

You must connect to the Qlik Sense app containing the objects you want to display on your web page. You do this with the qlik.openApp method.

Example:  

var config = {
	host: "myhost.com",
	prefix: "/",
	port: window.location.port,
	isSecure: true
};
require(["js/qlik"], function(qlik) {
	// open the app
	var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config);
	// insert Qlik objects into the page.
	app.getObject(document.getElementById('LB01'), 'uPyZavD');
}

You can also have multiple apps open at the same time.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
var config = {
	host: "myhost.com",
	prefix: "/",
	port: window.location.port,
	isSecure: true
};
var app2 = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config);

In return you get an app JavaScript object with app methods.

App API

Set a specific language

You can set a specific language for the Qlik Sense session. It should be defined before the app is opened, meaning the qlik.setLanguage method should be called before the qlik.openApp method is called.

var config = {
	host: "myhost.com",
	prefix: "/",
	port: window.location.port,
	isSecure: true
};
require(["js/qlik"], function(qlik) {
  //set the language to something else than default language
  qlik.setLanguage('es-EN')
  //open apps -- inserted here --
  var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config);
	// insert Qlik Sense objects into the page
	app.getObject(document.getElementById('LB01'), 'uPyZavD');
}

Get a global reference and access the Global API

You can open a WebSocket connection to the Qlik Associative Engine by calling the qlik.getGlobal method and get a JavaScript object in return, containing global methods.

var config = {
	host: window.location.hostname,
	prefix: "/",
	port: window.location.port,
	isSecure: true
};
var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
	alert('User:'+reply.qReturn);
});

Global API

Did this information help you?

Can you tell us why it did not help you and how we can improve it?