| name | querying-dune |
| description | Executes SQL queries on Dune Analytics and writes results as CSV to /tmp.
Use when the user needs blockchain data from Dune or wants to run a saved Dune query by ID.
Triggers: "dune query", "dune sql", "query dune", "blockchain data"
|
| compatibility | Python 3.10+, Bash, DUNE_API_KEY in .env or environment |
Dune SQL
Dune Documentation Reference
If there is any uncertainty about how to run a query or what data is available: use Web tools to find the answer in the Dune docs:
Running Direct SQL (Plus Feature)
Run scripts/run.sh to execute SQL:
SKILL_DIR="$HOME/.agents/skills/dune-sql"
"$SKILL_DIR/scripts/run.sh" "SELECT * FROM ethereum.transactions LIMIT 100"
"$SKILL_DIR/scripts/run.sh" -o txns.csv "SELECT * FROM ethereum.blocks LIMIT 10"
"$SKILL_DIR/scripts/run.sh" -p large "SELECT * FROM ethereum.transactions LIMIT 1000"
Running Saved Queries by ID
Run scripts/query.sh to execute a saved query:
"$SKILL_DIR/scripts/query.sh" 1215383
"$SKILL_DIR/scripts/query.sh" -o my_query.csv 1215383
"$SKILL_DIR/scripts/query.sh" --params '{"token": "USDC", "min_amount": 1000}' 1215383
Exit Codes
0 → Query succeeded, CSV written
1 → Error (SQL error, API error, config error)
2 → Query timed out or failed
References
Scripts:
Documentation:
- references/query-engine.md - DuneSQL overview, Trino basis, optimization
- references/data-types.md - varbinary, uint256, timestamps, conversions
- references/functions.md - bytearray, date/time, aggregates, window functions
- references/tables.md - Raw tables, decoded tables, curated spellbook tables
- references/examples.md - Comprehensive query examples