Metabase is an open-source BI tool, where you can store data, connect to outside data sources, query, and visualizing data. This article talks about when we have data stored in Metabase, how do we query the data and get results in Python. The first part of this article talks about how to use the Metabase rest API to query data. The second part tries out a Python API. Let’s get started.

Metabase rest API

Get session token

To use the Metabase rest API, we first need to get a session token. In the command line type the following:

curl -X POST \
	  -H "Content-Type: application/json" \
	  -d '{"username": YOUR_USER_NAME, "password": YOUR_PASSWORD}' \
	  https://metabase.YOUR_ENDPOINT.xxx/api/session

The output will be your token. Then save this token in your Python script or Jupyter Notebooks.

token = "YOUR_TOKEN"

#api #data-science #metabase #python

Query Metabase data in Python
13.80 GEEK