qlik-cli

qlik-cli, known on the command line simply as qlik, is a command line interface for Qlik Sense SaaS. It provides access to all public APIs through the command line, making it easier to script and automate new and old workflows such as:

  • Import, export, publish, and republish apps.
  • Create, rename, remove, and update spaces and assign user access.
  • Build, analyze, and edit apps.
  • Administer tenants.
qlik-cli example commands

The tool comes with built-in documentation, which is accessed by appending the --help flag to any command.

Installation

qlik-cli is available for MacOS, Microsoft Windows, and Linux either using a package manager or by downloading the tool's binary. Using a package manager makes it easier to update since it offers an upgrade option.

It's recommended to apply completion after installation to improve usability.

MacOS using brew

qlik-cli can be installed through Homebrew by adding the qlik-oss tap (this only needs to be done once):

brew tap qlik-oss/taps

and install the tool.

brew install qlik-cli

To update the tool, you run:

brew upgrade qlik-cli

Windows using chocolatey

qlik-cli supports installation on Windows through the package manager chocolatey by adding nuget.org as a source:

choco source add --name=nuget.org --source=https://www.nuget.org/api/v2

and install the tool:

choco install qlik-cli

If you prefer to not add the source, you can use:

choco install qlik-cli --source=https://www.nuget.org/api/v2

To update the tool, you run:

choco upgrade qlik-cli

Completion

To increase usability by decreasing the number of calls required when navigating and exploring the tool and resources, qlik-cli supports completion for bash, zsh and ps. By double tapping the tab key, qlik-cli suggests or autocompletes commands, flags, and resources.

Bash and zsh completion

To load completion in your shell, you can write the following snippet:

. <(qlik completion <shell>)

where shell should be one of bash or zsh. You can also add this to your shell profile, for example, ~/.bashrc or ~/.zshrc, if you want to include completion on startup (recommended). A robust way of doing so is the following:

if [ $(which qlik) ]; then
  . <(qlik completion <shell>)
fi

Note: Auto completion requires bash-completion to be installed on bash and zsh.

Powershell completion

There is partial completion support for Powershell. To user it, you need to create a Powershell profile. If you don't have one, you can run the following to create an empty profile:

if ( -not (Test-Path $PROFILE) ) {
  echo "" > $PROFILE
}

When you have a profile and installed qlik-cli, add the following snippet to your profile:

qlik completion ps > "./qlik_completion.ps1" # Create a file containing the powershell completion.
. ./qlik_completion.ps1                      # Source the completion.

The last thing you have to do is to restart the shell.

Get started

Authentication to a Qlik Sense SaaS tenant is done by providing the URL to the tenant as well as an API key To quickly get started, you can use the qlik-cli command qlik context init to guide you through the process and store the details locally.

$ qlik context init
Acquiring access to Qlik Sense SaaS
To complete the setup you have to have the 'developer' role and have
API-keys enabled. If you're unsure, you can ask your tenant-admin.

Specify your tenant URL, usually in the form: https://<tenant>.<region>.qlikcloud.com
Where <tenant> is the name of the tenant and <region> is eu, us, ap, etc...
Enter tenant url:

If you have multiple users or tenants, you can list and switch between them through the qlik context lsand qlik context use <context-name>.

Most commands return the full API response as json. If you are only interested in the created or requested resource id, you can add the quiet flag --quiet to suppress all but the ID output.

Examples

You can try out the tool with one of the following common use cases. For more examples, refer to the tool documentation.

Import a local app

Import a locally stored app to cloud.

qlik app import -f the_app.qvf

More information about the app resource can be found in qlik app --help.

Search for an app by name

qlik item ls --resourceType app --name "app name"

More information about the app resource can be found in qlik item --help.

Create a managed space and assign users

First you create the space and copy the returned ID.

qlik space create --name "Demo Space" --type managed --quiet

Then you assign a user with consumer, contributor, and publisher access by supplying the ID returned by the first call.

qlik space assignment create --spaceId=<ID> --type user --roles consumer,contributor,publisher --assigneeId=<userid> -q

More information about the app resource can be found in qlik space --help.

List failed reloads

To list all your reloads you enter:

qlik reload ls

Since this list can become very extensive, you probably want to employ some type of sorting or selection tool. jq is one such tool and can be used to filter out all failed reloads from the list.

qlik reload ls | jq '.[] | select(.status == "FAILED")'

More information about the app resource can be found in qlik reload --help.

Analyze an app

With qlik app meta, you get an overview of the app with information about its fields, tables, and associations.

qlik app meta --app <appid/app_name>

You can drill down even further and evaluate dimensions or measures.

qlik app eval --app <appid/app_name> 'Avg(Revenue)' by 'Country'

More information about the app resource can be found in qlik app eval --help.

Third-party dependencies

The tool uses third-party dependencies listed here .

Was this page helpful?