Simple steps to use Pyramid Java Script API to retrieve Realtime Data, customize and display in external Web application

Overview

Pyramid Analytics is a Robust Analytics and Business Intelligence Platform which is used to process data from multiple sources and also create rich interactive reports and dashboards to gain insights.

Pyramid provides a wide array of features in its User Interface for enterprise users to help easily embed these dashboards in other web applications too.  This can be achieved programmatically using the Pyramid JavaScript API as well.

These JavaScript API can also be used to retrieve only the relevant data from the reports and dashboards in a specified format, like CSV (comma-separated values), JSON (JavaScript Object Notation), and XML (extensible markup language), to formatted and display or used in external applications. 

Continuing our series of posts to explore and understand the power of Pyramid Analytics, in this post, we are going to show how the Javascript API can be used to retrieve data in the required format by passing relevant parameters so that this information can be used in external web applications to create customized visualizations while the Data can be retrieved in real-time from Pyramid acting as a single version of the truth.

Enclosed is a sample of such custom web application visualization created by retrieving data from Pyramid.

Authentication with Pyramid and Retrieval of Token

The first step in using JavaScript API calls is to authenticate with the Pyramid server using the respective user credentials and retrieve a token to be used in subsequent API calls: 

  • API to Authenticate and Retrieve Token:  “auth/authenticateUser”

Fig;1.1 Following Code section illustrates the process of retrieval of authenticated token from the Pyramid server via JavaScript API

// NOTE: callApi method is a generic. REST method is shown below.let token = callApi(“auth/authenticateUser”,{ “data”:{ “userName”:”admin”, “password”:”password” }},false);

Accessing or retrieval of the query result data

Once we are done with the retrieval of the token from the Pyramid server, we can use this token in our webpage to get access to the required data either from a Discovery/Publication/Presentation stored in the Pyramid Server.

Given below is the API that will be required to get access to the query result data from Discovery. This will be done by passing the respective options along with the authentication token.

  • API: “query/extractQueryResult”
  • Report ID: Id of the discovery.
  • ExportType: the export type in which you wish to see the data (JSON/CSV/XML).

Given below is FIg: 1.2 (code), which illustrates the access of the data in a specified JSON format by using the authenticated token from the Pyramid server with the help of javascript API. 

// NOTE: callApi method is generic. REST method is shown below.let queryResult = callApi(“query/extractQueryResult “,{   “data”: {      “itemId”:reportId,      “exportType”:0, //JSON         },   “auth”: token});

Fig: 1.2 (code)

Parameterization/filtering of the query result data 

There is also a way for us to Filter and retrieve only required data from Discovery, Publication or Presentation in the Pyramid Server by passing relevant parameters to the API. 

The API options that we require for the filtering of the retrieval data during JavaScript API calls on our web page is:

Option : externalParameters -> reportFilters

Fig: 1.3(Code) shown below illustrates the accessing of the data in a JSON format by using the authenticated token from the Pyramid server by using JavaScript API with Filtered/Parameterized data.

// NOTE: callApi method is generic. REST method is shown below.let queryResult = callApi(“query/extractQueryResult “,{   “data”: {      “itemId”:reportId,      “exportType”:0, //JSON      “exportOptions”: {},       “externalParameters”: {       “reportFilters”: [{                   “value”: “[customers].[Country].[Filters].&[United States]”            }, {                    “value”: “[customers].[State].[Filters].&[Alabama]”            }]      }   },   “auth”: token});

Fig: 1.3 (code)

Fig: 1.4(Code) illustrates the JavaScript generic REST API calling the principal method which will be used to process the JavaScript API Call and to process the request of the API by reading its respective data options and would then provide a resultant data in JSON format.

// NOTE: callApi method is a generic REST method Calling method shown below will be called for respective API calls..function callApi(path,data,parseResult=true){console.log(‘path = ‘,path);console.log(‘data = ‘,data);console.log(‘parseResult = ‘,parseResult); var xhttp = new XMLHttpRequest(); xhttp.open(“POST”, pyramidURL+path, false); xhttp.send(JSON.stringify(data)); console.log(‘Called – xhttp.responseText = ‘,xhttp.responseText); if(parseResult){ return JSON.parse(xhttp.responseText); }else{ return xhttp.responseText; }}

Fig: 1.4 (code)

Hope you enjoyed this article on Pyramid, stay tuned for more tips and tricks in coming articles. Please contact us to help with your implementations of Pyramid, we can help extend and customize Pyramid as per your requirements.

Shopping Basket

MicroFocus Vertica Analytics Platform delivers speed, scalability, and built-in machine learning that today’s most analytically intensive workloads demand, whether in the Public Clouds, On-Premises, on Hadoop, or any Hybrid combination. Vertica’s SQL Data Warehouse is trusted by the world’s leading data-driven companies, including Cerner, Etsy, Intuit, Uber and more to deliver speed, scale and reliability on mission-critical analytics. Vertica combines the power of a high-performance, massively parallel processing SQL query engine with advanced analytics and machine learning so you can unlock the true potential of your data with no limits and no compromises. We are a certified System Integration and reseller partner of Vertica and have a strategic alliance to develop industry-specific solutions using this Award-winning Columnar Database in the APAC region.

We have extensive experience with the entire product suite having successfully completed over 50 implementations in the USA/Europe/Asia Pacific across different industries and still continue to support a few key customers Globally.

As a Future-ready and complete, enterprise-grade analytics platform, Pyramid is a compelling option for organizations. Pyramid offers an integrated suite for modern Analytics and Business Intelligence requirements. It has a broad range of analytical capabilities, including data wrangling, ad hoc analysis, interactive visualization, analytic dashboards, mobile capabilities and collaboration in a governed infrastructure. It also features an integrated workflow for system-of-record reporting. Its Augmented features such as Smart Discovery, Smart Reporting, Ask Pyramid (NLQ), AI-driven modelling, automatic visualizations and dynamic content offer powerful insights to all users, regardless of skill level and the adaptive augmented analytics platform covers the entire data life cycle out-of-the-box, from ML-based data preparation to automated insights and automated ML model building. Pyramid is especially useful for the customer who is in urgent need to get more value out of their existing SAP BW and SAP HANA investments. Without any data extraction or duplication, Pyramid offers best-in-class functionality and performance that preserves the security and governance inherent in the SAP platform. We are a Strategic System Integration and Reseller partner of Pyramid Analytics.