Hi All, I need to export the entire dashboard to use it else where. Is this possible?
If not, I’ve tried to export at query level but I’m getting errors.
I navigated to my query, I clicked on ‘show API Key’
Copied the API Key and query URL and did this two lines of code: pip install click requests and python query_export.py --redash-url "https://app.redash.io/<slug>" --api-key "<api-key>"
The return I got was:
ValueError: No JSON object could be decoded
and if I used the link from the pop up window, I get:
KeyError: ‘results’
Just to check… by “export the entire dashboard”, are you meaning make it public so people without a Redash account (on the server) are able to view it, or are you meaning something else?
Oh. No, not making it public. I would like to save the queries as a file. I am planning to use it else where. Also, I have parameters, I realised I can’t set the dashboard to ‘allow public access’
Is there anyway to go about doing this? Open to other suggestions as well. Thank you
I’m actually trying to export the dashboard. I want to transport my data to a different platform.
I’ve tried API requesting, (as in my initial problem) using the given script.
Traceback (most recent call last):
File "query_export.py", line 49, in <module>
main()
File "/Users/nicholas/Library/Python/2.7/lib/python/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/nicholas/Library/Python/2.7/lib/python/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/nicholas/Library/Python/2.7/lib/python/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/nicholas/Library/Python/2.7/lib/python/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "query_export.py", line 44, in main
queries = get_queries(redash_url, api_key)
File "query_export.py", line 21, in get_queries
queries.extend(response['results'])
KeyError: 'results'
I’ve managed to get a clearer error message. I took the exact same file as query_export.py.
Sounds like progress is being made, though it’s going a bit slowly.
One thing springs to mind… what the version of Redash running on the server you’re querying?
Asking because the list of API end points I gave above was correct for the current development version at the time of writing it. Didn’t think of that at the time.
If you can find out the version of Redash on the running server, it shouldn’t be hard to get the correct list for that version. It will probably just be an earlier point in time for the same api.py file.
Thank you so much for your help. I researched and learnt enough to be able to export all my queries in SQL files. Hurray! I used the same python script provided by Redash.
To go deeper into exporting, how do I export only the queries from my favourite list or just selected queries. Eg query #48.
I tried editing the path in the script to…
path = "{}/api/queries/favourites".format(url)
and
path = "{}/api/queries/48".format(url)
but still, all queries are exported. May I trouble you to enlighten me if I’m on the correct path? Thanks a bunch
Looking into the API in good depth is on my near term ToDo list, but it’s behind a few other things which need doing first. Will probably have time to investigate later on today, or maybe tomorrow. Will keep this in mind when doing so though.
Oh, did you find out the version of Redash that’s running on your target server? Would be useful, so I can check if things have changed from that version to the current one, while I’m at it.
Sorry for the delay, and no firm answer yet either.
Started putting together initial pieces for an API doc (manually), with the idea of creating working examples for each function. Obviously, there is a long, long way to go as nearly everything atm is “To Do”:
So far, it looks like most of the API calls there are “read only”. eg useful for querying data.
I still need to figure out how to create things (eg new data source) with the API. That would probably be useful for you too. eg import queries from API on server one, then create selected queries from that on server too.