metabase-http-driver
metabase-http-driver copied to clipboard
A proof-of-concept HTTP "driver" for Metabase
HTTP Metabase Driver
This is a proof-of-concept HTTP "driver" for Metabase.
Previous discussion: https://github.com/metabase/metabase/pull/7047
Usage
Currently the simplest "native" query for this driver is simply an object with a url
property:
{ "url": "https://api.coinmarketcap.com/v1/ticker/" }
The driver will make a GET
request and parse the resulting JSON array into rows. Currently it only supports JSON.
You can provide a different method
as well as headers
and a JSON body
:
{
"url": "https://api.coinmarketcap.com/v1/ticker/",
"method": "POST",
"headers": {
"Authentication": "SOMETOKEN"
},
"body": {
"foo": "bar"
}
}
Additionally, you can provide a result
object with a JSONPath to the "root" in the response, and/or a list of fields
:
{
"url" : "https://blockchain.info/blocks?format=json",
"result" : {
"path" : "blocks",
"fields": ["height", "time"]
}
}
You can also predefine "tables" in the database configuration's Table Definitions
setting. These tables will appear in the graphical query builder:
{
"tables" : [
{
"name" : "Blocks",
"url" : "https://blockchain.info/blocks?format=json",
"fields" : [
{ "name" : "height", "type" : "number" },
{ "name" : "hash", "type" : "string" },
{ "name" : "time", "type" : "number" },
{ "type" : "boolean", "name" : "main_chain" }
],
"result" : {
"path" : "blocks"
}
}
]
}
There is limited support for aggregations and breakouts, but this is very experimental and may be removed in future versions.
Building the driver
Prereq: Install Metabase as a local maven dependency, compiled for building drivers
Clone the Metabase repo first if you haven't already done so.
cd /path/to/metabase_source
lein install-for-building-drivers
Build the HTTP driver
# (In the HTTP driver directory)
lein clean
DEBUG=1 LEIN_SNAPSHOTS_IN_RELEASE=true lein uberjar
Copy it to your plugins dir and restart Metabase
mkdir -p /path/to/metabase/plugins/
cp target/uberjar/http.metabase-driver.jar /path/to/metabase/plugins/
jar -jar /path/to/metabase/metabase.jar
or:
mkdir -p /path/to/metabase_source/plugins
cp target/uberjar/http.metabase-driver.jar /path/to/metabase_source/plugins/
cd /path/to/metabase_source
lein run