Consume a Data Export Using the Visier Data Export API

Fetch data from Visier using the Visier Data Export API.

Who can use this feature?

Users with this permission capability:

  • Consume Data Exports

Not sure if you have this feature or capability? Reach out to your administrator.

Prerequisites: To perform this task you'll need a Data Export link, which may be provided by another user. For more information, see Generate a Data Export Link.

The Visier Data Export API allows developers to pull data using a programming language. Use the following snippets to send requests to get data from Visier using the Data Export link.

If you make changes to your Data Export in Visier, you must manually refresh the data in your third-party tool or web application to see the updates. When you refresh, the updated data will overwrite the existing data.

Note: You may encounter an error when refreshing your data if the display name of a metric or attribute used in your Data Export has been changed in the studio experience. To fix this, you will have to update the name used in the third-party tool or web application and try again.

Java

When using this snippet, replace the username, password, and dataConnectorUrl parameters with the required information.

Copy
//enter your credentials
String username = "john@mycompany.com";
String password = "MyPassword";
//enter your data Export URL from the Visier app
String dataConnectorUrl = "https://mycompany.api.visier.io/api/dataconnector/getData?id=22c73ec6-f82e-1578-2333-fb974dd184d1&apikey=RBtkZt8MpXa045IpA2QpdirztNTznTSr";

//Encode the username and password to base64
byte[] encodedBytes = Base64.getEncoder().encode((username +":"+ password).getBytes());
String authorization = "Basic " + new String(encodedBytes);

String requestMethod = "GET";
URL obj = new URL(url);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod(requestMethod);

// Set request headers
connection.setRequestProperty("Authorization", authorization);

// Response code
int responseCode = connection.getResponseCode();

// Set up reader
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

String inputLine;
StringBuffer response = new StringBuffer();

// Read from connection
while ((inputLine = in.readLine()) != null) {
     response.append(inputLine);
}

 PrintStream out = new PrintStream(new FileOutputStream("dataConnector_results.txt"));
 System.setOut(out);
 System.out.println(response);

 in.close();

Python

When using this snippet, replace the username, password, and dataConnectorUrl, and params parameters with the required information.

Note: Python3 and the request module are required.

Copy
import requests
import base64

username = "john@mycompany.com"
password = "MyPassword"
dataConnectorUrl = "https://mycompany.api.visier.io/api/dataconnector/getData"
params = {"id":"22c73ec6-f82e-1578-2333-fb974dd184d1","apikey":"RBtkZt8MpXa045IpA2QpdirztNTznTSr"}

authorization = "Basic {}==".format(base64.b64encode(bytes("{}:{}".format(username,password),"utf-8")).decode("utf-8"))
header = {"Authorization":authorization}
r = requests.get(dataConnectorUrl, params=params, headers=header)

print("Status code: {}".format(r.status_code))
f=open('dataConnector_results.txt','wb')
f.write(r.content)
f.close()

R

When using this snippet, replace the username, password, and dataConnectorUrl parameters with the required information.

Note:  

  • The following script was written for R version 3.6.3.
  • The httr package is required.
Copy
library(httr)
require("httr")

username <- "john@mycompany.com"
password <- "MyPassword"

dataConnectorURL <- "https://mycompany.api.visier.io/api/dataconnector/getData?id=22c73ec6-f82e-1578-2333-fb974dd184d1&apikey=RBtkZt8MpXa045IpA2QpdirztNTznTSr"
request <- content(GET(dataConnectorURL, authenticate(username,password)), as="text")
write(request,file="dataConnector_results.txt")

Data structure for Aggregated Data Exports

When consuming an Aggregated Data Export, you may notice differences in how the data is structured in Visier and your third-party tool or web application:

  • Hierarchy structures will not be preserved when you consume the Aggregated Data Export.

    For example, your Aggregated Data Export includes the Location Hierarchy grouping. You can expand and collapse these rows to drill down to view data at the Region, Country, or State levels in Visier.

  • The hierarchical information used to show the relationship between data will not be included in the export. As a result, attribute members of the hierarchy will appear in a single column in the third-party application, as shown in the following screenshot.

  • Columns that contain mixed data types will be exported as strings. For example, if a column in the Aggregated Data Export contains strings (Exceptional, Good, Poor) and numbers (10.3% 39.0%, 89.7%). The data type for this column in the third-party application will be string.
  • Currency codes and percentage symbols will not be included when you consume the Aggregated Data Export.

    For example, the currency codes and percentage symbols appear alongside the amount in the Aggregated Data Export.

    However, you will only see the amount in the third-party application, as shown in the following screenshot.