> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dune.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

### Set up a new repo from the GitHub template

Use [this GitHub template](https://github.com/duneanalytics/DuneQueryRepo) to create your own repository, then follow these steps:

1. Generate an API key from your Dune account and put that in both your `.env` file and [github action secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) (name it `DUNE_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.*

2. Type your intended query ids into the `queries.yml` file. The id can be found from the link `https://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.

3. 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

1. 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.

2. 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 be `dune.team_name.dataset_<filename>`.

<Tip>
  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>`.
</Tip>

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.
