npx skills add https://github.com/duneanalytics/skills --skill dune假设 Dune CLI 已安装并完成身份验证。请勿预先运行安装或身份验证检查。直接执行请求的 dune 命令即可。
如果 dune 命令执行失败,请检查错误以确定原因,并按照 install-and-recovery.md 中的恢复步骤操作:
Dune 的命令行界面——领先的区块链数据平台。使用它来编写和执行针对链上数据的 DuneSQL 查询、发现数据集、搜索文档以及监控积分使用情况。
除 docs search 外的所有命令都需要通过 Dune API 密钥进行身份验证。密钥按以下优先级顺序解析:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 1. 标志(最高优先级——覆盖所有其他方式)
dune query run 12345 --api-key <key>
# 2. 环境变量
export DUNE_API_KEY=<key>
dune query run 12345
# 3. 保存的配置文件(最低优先级)
dune auth --api-key <key> # 保存到 ~/.config/dune/config.yaml
dune query run 12345 # 使用保存的密钥
要以交互方式保存密钥(从 stdin 提示输入):
dune auth
配置文件位置:~/.config/dune/config.yaml
| 标志 | 描述 |
|---|---|
--api-key <KEY> | Dune API 密钥(覆盖 DUNE_API_KEY 环境变量和保存的配置) |
大多数命令支持 -o, --output <FORMAT>,其值为 text(默认,人类可读的表格)或 json(机器可读)。
在所有支持的命令上始终使用
-o json。JSON 输出比text包含更多细节(完整的 API 响应对象 vs. 汇总的表格),并且解析时没有歧义。text格式适用于人类在终端使用,会省略一些字段。
Dune 使用 DuneSQL(一种基于 Trino 的 SQL 方言)作为其查询引擎。要点:
--sql 标志或保存的查询的所有 SQL 必须是有效的 DuneSQLdune docs search --query "DuneSQL functions" 来查找语法和函数查询执行支持两个层级:
| 层级 | 标志值 | 描述 |
|---|---|---|
| 中等 | medium(默认) | 标准计算资源。适用于大多数查询。 |
| 大型 | large | 更高的计算资源。用于复杂查询、大型连接或繁重的聚合。消耗更多积分。 |
提交查询后,执行过程会经历以下状态:
| 状态 | 含义 | 操作 |
|---|---|---|
QUERY_STATE_PENDING | 已排队等待执行 | 等待 |
QUERY_STATE_EXECUTING | 当前正在运行 | 等待 |
QUERY_STATE_COMPLETED | 结果可用 | 获取结果 |
QUERY_STATE_FAILED | 执行失败 | 检查错误信息;修复 SQL 并重试 |
QUERY_STATE_CANCELLED | 被用户或系统取消 | 如有需要,重新执行 |
| 类别 | 描述 |
|---|---|
canonical | 核心区块链数据(区块、交易、追踪、日志) |
decoded | ABI 解码的合约数据(事件和函数调用) |
spell | Dune Spellbook 转换表(经过整理的、更高级别的表,如 dex.trades) |
community | 社区贡献的数据集 |
| 类型 | 描述 |
|---|---|
dune_table | Dune 维护的核心表 |
decoded_table | 合约 ABI 解码表 |
spell | Spellbook 转换表 |
uploaded_table | 用户上传的 CSV/数据表 |
transformation_table | 物化转换表 |
transformation_view | 虚拟转换视图 |
参数允许您创建带有可变输入的可重用查询。将它们作为 --param key=value 传递(可重复)。API 会自动检测类型,但参数支持以下类型:text、number、datetime、enum。
dune query run 12345 --param wallet=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --param days=30 -o json
| 命令 | 描述 | 需要身份验证 |
|---|---|---|
dune auth | 将 API 密钥保存到配置文件 | 否 |
dune query create | 创建新的保存查询 | 是 |
dune query get <id> | 获取已保存查询的 SQL 和元数据 | 是 |
dune query update <id> | 更新现有查询 | 是 |
dune query archive <id> | 归档已保存的查询 | 是 |
dune query run <id> | 执行已保存的查询并等待结果 | 是 |
dune query run-sql | 直接执行原始 DuneSQL(无需保存查询) | 是 |
dune execution results <id> | 获取先前执行的结果 | 是 |
dune dataset search | 搜索 Dune 数据集目录 | 是 |
dune dataset search-by-contract | 查找合约地址的解码表 | 是 |
dune docs search | 搜索 Dune 文档 | 否 |
dune usage | 显示积分和资源使用情况 | 是 |
# 直接运行一次性查询
dune query run-sql --sql "SELECT block_number, block_time FROM ethereum.blocks ORDER BY block_number DESC LIMIT 5" -o json
# 1. 查找包含列模式的相关表
dune dataset search --query "uniswap swaps" --categories decoded --include-schema -o json
# 2. 使用发现的表/列名编写并执行 SQL
dune query run-sql --sql "SELECT * FROM uniswap_v3_ethereum.evt_Swap LIMIT 10" -o json
# 1. 查找特定合约的解码表
dune dataset search-by-contract --contract-address 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --include-schema -o json
# 2. 查询发现的表
dune query run-sql --sql "SELECT * FROM uniswap_v3_ethereum.evt_Transfer LIMIT 10" -o json
# 1. 创建带参数的保存查询
dune query create --name "Top Wallets" --sql "SELECT address, balance FROM ethereum.balances WHERE balance > {{min_balance}} LIMIT {{row_limit}}" -o json
# 2. 使用参数值运行它
dune query run <returned-id> --param min_balance=1000 --param row_limit=50 -o json
# 1. 提交但不等待
dune query run 12345 --no-wait --performance large -o json
# 输出: {"execution_id": "01ABC...", "state": "QUERY_STATE_PENDING"}
# 2. 稍后检查结果
dune execution results 01ABC... -o json
以下功能可通过 Dune MCP 服务器或 Web 界面使用,但不能通过 CLI 使用:
dune_ 为前缀的字符串或来自 DUNE_API_KEY 的值)。使用 [REDACTED] 将其编辑掉。query create、query update、query archive)之前与用户确认-o json —— JSON 输出更详细且可可靠解析--temp,以避免弄乱用户保存的查询--api-key。优先使用 dune auth 或 DUNE_API_KEY 环境变量。当您需要详细的命令语法和标志时,请加载相关参考:
| 任务 | 参考文档 |
|---|---|
| 创建、获取、更新或归档保存的查询 | query-management.md |
| 执行查询(run, run-sql)或获取执行结果 | query-execution.md |
| 搜索数据集或查找合约地址的表 | dataset-discovery.md |
| 搜索文档或检查账户使用情况 | docs-and-usage.md |
| DuneSQL 类型、函数、常见模式和陷阱 | dunesql-cheatsheet.md |
| CLI 安装、身份验证和版本恢复 | install-and-recovery.md |
每周安装量
203
代码仓库
GitHub Stars
6
首次出现
Mar 9, 2026
安全审计
安装于
codex200
opencode197
cursor197
gemini-cli196
cline196
github-copilot196
Assume the Dune CLI is already installed and authenticated. Do not run upfront install or auth checks. Just execute the requested dune command directly.
If a dune command fails, inspect the error to determine the cause and follow the recovery steps in install-and-recovery.md:
A command-line interface for Dune -- the leading blockchain data platform. Use it to write and execute DuneSQL queries against on-chain data, discover datasets, search documentation, and monitor credit usage.
All commands except docs search require authentication via a Dune API key. The key is resolved in this priority order:
# 1. Flag (highest priority -- overrides everything)
dune query run 12345 --api-key <key>
# 2. Environment variable
export DUNE_API_KEY=<key>
dune query run 12345
# 3. Saved config file (lowest priority)
dune auth --api-key <key> # saves to ~/.config/dune/config.yaml
dune query run 12345 # uses saved key
To save your key interactively (prompted from stdin):
dune auth
Config file location: ~/.config/dune/config.yaml
| Flag | Description |
|---|---|
--api-key <KEY> | Dune API key (overrides DUNE_API_KEY env var and saved config) |
Most commands support -o, --output <FORMAT> with values text (default, human-readable tables) or json (machine-readable).
Always use
-o jsonon every command that supports it. JSON output contains more detail thantext(full API response objects vs. summarized tables) and is unambiguous to parse. Thetextformat is for human terminal use and drops fields.
Dune uses DuneSQL , a Trino-based SQL dialect, as its query engine. Key points:
--sql flags or saved queries must be valid DuneSQLdune docs search --query "DuneSQL functions" to look up syntax and functionsQuery execution supports two tiers:
| Tier | Flag Value | Description |
|---|---|---|
| Medium | medium (default) | Standard compute resources. Suitable for most queries. |
| Large | large | Higher compute resources. Use for complex queries, large joins, or heavy aggregations. Costs more credits. |
After submitting a query, the execution progresses through these states:
| State | Meaning | Action |
|---|---|---|
QUERY_STATE_PENDING | Queued for execution | Wait |
QUERY_STATE_EXECUTING | Currently running | Wait |
QUERY_STATE_COMPLETED | Results available | Fetch results |
QUERY_STATE_FAILED | Execution failed | Check error message; fix SQL and retry |
QUERY_STATE_CANCELLED | Cancelled by user or system |
| Category | Description |
|---|---|
canonical | Core blockchain data (blocks, transactions, traces, logs) |
decoded | ABI-decoded contract data (events and function calls) |
spell | Dune Spellbook transformations (curated, higher-level tables like dex.trades) |
community | Community-contributed datasets |
| Type | Description |
|---|---|
dune_table | Core Dune-maintained tables |
decoded_table | Contract ABI-decoded tables |
spell | Spellbook transformation tables |
uploaded_table | User-uploaded CSV/data tables |
transformation_table | Materialized transformation tables |
transformation_view | Virtual transformation views |
Parameters let you create reusable queries with variable inputs. Pass them as --param key=value (repeatable). The API auto-detects the type, but parameters support these types: text, number, datetime, enum.
dune query run 12345 --param wallet=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --param days=30 -o json
| Command | Description | Auth |
|---|---|---|
dune auth | Save API key to config file | No |
dune query create | Create a new saved query | Yes |
dune query get <id> | Fetch a saved query's SQL and metadata | Yes |
dune query update <id> | Update an existing query | Yes |
dune query archive <id> | Archive a saved query |
# Run a one-off query directly
dune query run-sql --sql "SELECT block_number, block_time FROM ethereum.blocks ORDER BY block_number DESC LIMIT 5" -o json
# 1. Find relevant tables with column schemas
dune dataset search --query "uniswap swaps" --categories decoded --include-schema -o json
# 2. Write and execute SQL using discovered table/column names
dune query run-sql --sql "SELECT * FROM uniswap_v3_ethereum.evt_Swap LIMIT 10" -o json
# 1. Find decoded tables for a specific contract
dune dataset search-by-contract --contract-address 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --include-schema -o json
# 2. Query the discovered tables
dune query run-sql --sql "SELECT * FROM uniswap_v3_ethereum.evt_Transfer LIMIT 10" -o json
# 1. Create a saved query with parameters
dune query create --name "Top Wallets" --sql "SELECT address, balance FROM ethereum.balances WHERE balance > {{min_balance}} LIMIT {{row_limit}}" -o json
# 2. Run it with parameter values
dune query run <returned-id> --param min_balance=1000 --param row_limit=50 -o json
# 1. Submit without waiting
dune query run 12345 --no-wait --performance large -o json
# Output: {"execution_id": "01ABC...", "state": "QUERY_STATE_PENDING"}
# 2. Check results later
dune execution results 01ABC... -o json
The following capabilities are available via the Dune MCP server or web UI but not via the CLI:
dune_, or values from DUNE_API_KEY). Redact them with [REDACTED].query create, query update, query archive)-o json on every command -- JSON output is more detailed and reliably parseable--temp when creating throwaway queries to avoid cluttering the user's saved queries--api-key on the command line when other users might see the terminal history. Prefer or the environment variable.Load the relevant reference when you need detailed command syntax and flags:
| Task | Reference |
|---|---|
| Create, get, update, or archive saved queries | query-management.md |
| Execute queries (run, run-sql) or fetch execution results | query-execution.md |
| Search datasets or find tables for a contract address | dataset-discovery.md |
| Search documentation or check account usage | docs-and-usage.md |
| DuneSQL types, functions, common patterns, and pitfalls | dunesql-cheatsheet.md |
| CLI install, authentication, and version recovery | install-and-recovery.md |
Weekly Installs
203
Repository
GitHub Stars
6
First Seen
Mar 9, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykWarn
Installed on
codex200
opencode197
cursor197
gemini-cli196
cline196
github-copilot196
Excel财务建模规范与xlsx文件处理指南:专业格式、零错误公式与数据分析
44,500 周安装
| Re-execute if needed |
| Yes |
dune query run <id> | Execute a saved query and wait for results | Yes |
dune query run-sql | Execute raw DuneSQL directly (no saved query needed) | Yes |
dune execution results <id> | Fetch results of a previous execution | Yes |
dune dataset search | Search the Dune dataset catalog | Yes |
dune dataset search-by-contract | Find decoded tables for a contract address | Yes |
dune docs search | Search Dune documentation | No |
dune usage | Show credit and resource usage | Yes |
dune authDUNE_API_KEY