The Displayr API is useful for automating certain functions, such as setting up basic projects and/ or updating or merging data files.
It is rarely sensible to attempt to use the API to create beautiful online documents or advanced statistical analyses. It's much more sensible to create a single document in Displayr and use it as a template.
This article contains the steps required to get you started with the Displayr API.
- The API Documentation. The documentation can be found here. Please note that documentation is designed and written to be used by computer programmers.
- A PC running Windows.
- Python software.
- An Enterprise Displayr license with purchased View hours.
- Company secret credentials. To obtain your Company secret please contact Displayr support by emailing email@example.com.
- The createproject.zip containing a QScript, a chart template, and a data file.
- See Displayr API and Technical Reference for further details.
Step 1 - Install Python
- Download the installer: Windows x86-64 executable installer.
- Run the installer.
- Tick Add Python 3.9 to PATH (it's at the bottom of the screen).
- Press Customize installation.
- Press Next.
- Choose Precompile standard library (on Advanced Options screen).
- Click Install and wait for the installation to complete and press Close when it is complete.
- Open the Windows Command Prompt (press the Windows key on your keyboard, type Command, select Command Prompt).
- Run the following line of code in the command prompt:
pip install requests. This causes various things to be installed. Leave the command prompt open on your screen. We will use it later.
Step 2 - Download and update the createproject.py file
- Download the createproject zip file in the Requirements section above.
- Double-click on the file to open it.
The zip file contains multiple files including a Python script for creating projects (createproject.py).Save all the files somewhere on your computer or network.
- Open the createproject.py file using a text editor (eg Notepad if using Windows).
- On line 6, depending on the deployed region you may have to change the host_name.
- You can find out your Region by looking at the domain URL for your account. Depending on the Region change the host_name accordingly on lines 6 through 14 of the createproject.py file.
Region Host Name
- On line 42, insert the Company secret where it says insert-company-secret-here-(contact-displayr-support)
- On line 45 replace insert-new-document-name-here with your desired name for the document to be created. If you wish to overwrite an existing document you will need to first delete that document (otherwise, you will see the message Check that the project name is unique).
- Save the file.
Step 3 - Run the API Script
- Find the folder containing the API script files in Windows Explorer, and copy the file path (eg C:\Users....\DisplayrAPIClient).
- Open the Windows Command Prompt by pressing the Windows key on your keyboard and typing Command into the search bar, and selecting Command Prompt.
- Type cd and then space and Ctrl-V to paste in your path and press Enter (eg, cd C:\Users....\DisplayrAPIClient).
- Type the name of your file (eg createproject.py unless you renamed the file) and press Enter.
- Windows will likely confirm that you want to run this using Python; check \Always use this app to run .py files and press OK.
- OPTIONAL: In case the script doesn't run, repeat Step 4.
- If you don't get an error, Windows will return an output, the bottom of which will look similar to the below.
:b'<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <title>API/ImportUpdatedData Output</title>\r\n</head>\r\n<body>\r\n<h1>Success</h1>\r\n\r\n\r\n</body>\r\n</html>'
- In Displayr, go to or refresh your Documents page and confirm a new document was created.