Query Management
In this quickstart, we will walk through how to turn any dashboard (or set of queries) into a GitHub repository that uses our query management API.
Prerequisites
- Python environment set up (check out Anaconda Navigator if you want somewhere to start.)
- Have a Dune API key from the team/user who’s queries you want to manage (to obtain one follow the steps here)
Set up a new repo from the GitHub template
Use this GitHub template to create your own repository, then follow these steps:
-
Generate an API key from your Dune account and put that in both your
.env
file and github action secrets (name itDUNE_API_KEY
). You can create a key under your Dune team settings. The api key must be from a plus plan for this repo to work. -
Type your intended query ids into the
queries.yml
file. The id can be found from the linkhttps://dune.com/queries/<query_id>/...
. If you’re creating this for a dashboard, go to the dashboard you want to create a repo and click on the “github” button in the top right of your dashboard to see the query ids. -
Then, run
pull_from_dune.py
to bring in all queries into/query_{id}.sql
files within the/queries
folder. Directions to setup and run this python script are below.
Updating Queries or CSV Tables
-
Make any changes you need to directly in the repo. Any time you push a commit to MAIN branch,
push_to_dune.py
will save your changes into Dune directly. You can run this manually too if you want. -
For CSVs, update the files in the
/uploads
folder.upload_to_dune.py
will run on commit, or can be run manually. The table name in Dune will bedune.team_name.dataset_<filename>
.
You can press the “github” button on your own dashboard to get a list of query ids, or you can just paste in any query ids yourself. The query id comes from the url, dune.com/queries/<query_id>/<visualization_id>
.
Anytime you commit a change to the repo, it will now update your queries in the app too. You can run pull_from_dune.py
anytime to update the repo with any changes from the app.
Was this page helpful?