NOTE: From version 5.2.2 of Open Source BI Helical Insight, we have provided DIRECT inbuilt support to REST API driver. This method is much more simpler to use and recommended. Please refer to this link to learn more : https://www.helicalinsight.com/connect-and-use-an-api-as-a-data-source-in-helical-insight-5-0/ If you are using older version or want to use Apache drill, then continue to read the below.
In this blog we are going to cover how to connect to an API / HTTP requests from Open Source BI product Helical Insight and use that to create reports.
Introduction : Apache drill has introduced HTTP storage plugin from drill version 1.18 and onwards. The HTTP storage plugin lets you query APIs over HTTP/REST. The plugin expects JSON or CSV responses. In this document we will cover how to create HTTP plugin and how to connect it with Helical Insight application.
You may refer to our other blogs to learn about how to download and install Apache Drill.
To configure the plugin, create a new storage plugin in Apache drill with any name (we have given name as http) and add configurations within this storage plugin. Below we have provided sample configuration of one of the API, which we are using as an example for this document :
{ "type": "http", "cacheResults": false, "connections": { "population": { "url": "https://datausa.io/api/data?drilldowns=State&measures=Population", "method": "GET", "headers": null, "authType": "none", "userName": null, "password": null, "postBody": null, "params": [ "year" ], "dataPath": "data", "requireTail": false, "inputType": "json" } }, "timeout": 0, "proxyHost": null, "proxyPort": 0, "proxyType": "direct", "proxyUsername": null, "proxyPassword": null, "enabled": true }
As you can see above, within connections we can provide our API url, method (GET OR POST), parameters, headers, authentication, datapath etc. Using above configurations we have created http storage plugin within Apache drill 1.18.
NOTE : It is mandatory to define the key name of output response from API into dataPath.
Learn about creating the plugins on apache drill here.
For example we have an API:
API : https://datausa.io/api/data?drilldowns=State&measures=Population
Output of this API : {"data":[{"ID State":"04000US01","State":"Alabama","ID Year":2019,"Year":"2019","Population":4903185,"Slug State":"alabama"}]}
So within dataPath we need to define the JSON object key within which we see the response. In our case it is data and hence we defined dataPath as data. Once we have created http storage we can then connect apache drill with Helical Insight application from Datasources page.
Now go to metadata creation page and add any random table to metadata, this needs to be done in order to create a metadata view.
Create metadata Query view, in our case we have created this using SQL : select * from http.population
Save the metadata and go to report creation page for creating a report. Select the metadata which you have just now created to use.
Save the report. You can create N number of reports and dashboards by following same method.
Reference : https://drill.apache.org/docs/http-storage-plugin/