I like how the /query url works and you can download all of the SQL for each query. Handy. I’m trying to figure out the utility of the /dashboard/ API. I would sort of expect it to be similar to how you could import/build a dashboard using JSON parameters. But, I’ve looked at the dashboard output, and while I can see name, creator, user, etc. I don’t see any information about how it configures an actual visualization for a dashboard. Is there meant to someday be a separate API call for visualizations, or am I just missing it? All I can see is a big list of numbers in ‘layout’ which appears to be describing the layout of a dashboard, but no real useful way to take that information and build a dashboard in another Redash instance.
Ideally, the way to dump the visualizations in JSON format would be readily available so that it would be easy to recreate a dashboard on another instance, referencing the right queries, x axis, y axis, visualization type, groupings, stacking, etc.
Can you share the contents of export_dashboard.py? Otherwise we can only guess…
The dashboards endpoint isn’t going to spit out everything you need to reconstruct a dashboard because that would mean duplicating data. The building blocks of Redash are queries. Queries can have visualizations. Dashboards contain widgets. Widgets may either be text boxes or references to visualizations. So a dashboard object is really just a list of references to visualizations and info about how to position those widgets on a screen.
To fully re-assemble a dashboard you will need to fetch its definition (position info and any text box widgets), then duplicate the queries and their visualizations which are referenced from the dashboard object. This is how the migration script works.
I can, but it’s a minor variation of export_query.py from redash_toolbelt, it just uses the dashboard API instead of query to collect the json.
def save_dashboards(dashboards):
for dash in dashboards:
filename = ‘dashboard_{}.json’.format(dash[‘id’])
pprint(dash)
The thing I’m interested in is the widget definition, fields, etc. But, I don’t see a way to get the widgets out. The dashboard itself is secondary, it’s the definitions to build the widgets that I’d love to be able to just export use to rebuild.
Please share your dashboard export script. What you describe is totally possible (it’s how the semi-official migration script works). But it sounds like your version has a bug that corrupts the widget definition and makes it None (the API cannot return a None definition for a widget ) . If you share your script we can find the bug.
Thanks. The problem here is the script never pulls the complete dashboard object from the API. It’s using the “list dashboards” endpoint (api/dashboards) which only includes information needed to display a list of dashboards. You can get the full dashboard object from api/dashboards/<url-slug>.