API endpoint for exporting chart image

Context
As a developer, I need to run automatically a query multiple times, changing the filter values each time, and export the png file locally for future uses (push to a remote document or cloud as instance).

Frustration
Metabase introduced in the version 0.47.0 the possibility to download a chart as a PNG file the same way it was possible to download in XLSX, JSON and CSV.

However, when looking at the API documentation, the provided endpoint (link here) doesn't provide the possibility to do so.
image

As a matter of fact, looking into the Network tab of Developer tools of my browser show a complete difference in implementation between the export of a data file and an image file (examples below).

Example of request made for downloading data file : simple to automate

Example of request made for downloading the PNG file : not so simple to automate

Solution
It would be awesome to complete the API endpoint with the possibility to export in PNG. I assume it requires some heavy work in code rewriting, therefore my question here in order to have feedback from people that may go through similar problems.

Alternatives

  • Scrapping our Metabase instance (using scrapping libs like Beautiful Soup): feasable but daunting

Png and pdf export are a frontend magic and not a backend process, that’s why you don’t see them as options in the endpoint

1 Like

For the sake of posterity, I drafted a script that scraps a specified indicator using Python + Selenium : Scrap a Metabase graph using Python + Selenium · GitHub