Overview
Perfect for data teams, researchers, and analysts who need to programmatically analyze onchain data, build custom reports, and create automated analytics pipelines.What You’ll Learn
- Execute SQL queries via API
- Retrieve and process results
- Handle query parameters
- Build analytics pipelines
- Filter and transform data
Prerequisites
- A Dune account (create one free)
- An API key (get your API key)
- Basic familiarity with SQL
Quick Start
1. Execute a Simple Query
Let’s start by executing a query to analyze recent DEX trading volume:The
run_sql() function in our Python SDK automatically handles query execution and polling for completion. With cURL, you’ll need to poll the execution status endpoint and then fetch results manually.2. Use Parameterized Queries
For reusable analytics, create queries with parameters:3. Build an Analytics Pipeline
Create a pipeline that runs multiple queries and combines results:4. Filter and Transform Results
Use Dune’s powerful filtering to refine results:Common Patterns
Scheduled Analytics
Run analytics on a schedule (e.g., with cron, Airflow, or cloud scheduler):Onchain Monitoring
Monitor specific metrics and trigger alerts:Next Steps
Execute Queries API
Full API reference for query execution
Result Filtering
Advanced filtering techniques
Materialized Views
Create and manage materialized views
DuneSQL Functions
Learn DuneSQL functions and operators
Example Use Cases
- Research Reports: Generate daily/weekly reports on DeFi protocols, NFT markets, or chain activity
- Automated Dashboards: Feed data to custom dashboards or BI tools
- Alert Systems: Monitor metrics and trigger alerts when thresholds are met
- Comparative Analysis: Compare metrics across chains, protocols, or time periods