Skip to main content
POST
/
v1
/
sql
/
execute
curl -X POST "https://api.dune.com/api/v1/sql/execute" \
  -H "Content-Type: application/json" \
  -H "X-Dune-Api-Key: YOUR_API_KEY" \
  -d '{
    "sql": "SELECT * FROM dex.trades WHERE block_time > now() - interval '\''1'\'' day LIMIT 10",
    "performance": "medium"
  }'
{
  "execution_id": "01HKZJ2683PHF9Q9PHHQ8FW4Q1",
  "state": "QUERY_STATE_PENDING"
}
Run arbitrary SQL queries via API. This endpoint allows you to execute SQL directly without first creating a query object, perfect for dynamic analysis and automated workflows.
When executing arbitrary SQL queries (queries not saved in Dune), the query_id in the response will always be 0. This is a placeholder value since these queries are not stored in the Dune database.

Pricing

This endpoint is usage-based and consumes credits based on the computational resources used during execution.
curl -X POST "https://api.dune.com/api/v1/sql/execute" \
  -H "Content-Type: application/json" \
  -H "X-Dune-Api-Key: YOUR_API_KEY" \
  -d '{
    "sql": "SELECT * FROM dex.trades WHERE block_time > now() - interval '\''1'\'' day LIMIT 10",
    "performance": "medium"
  }'
{
  "execution_id": "01HKZJ2683PHF9Q9PHHQ8FW4Q1",
  "state": "QUERY_STATE_PENDING"
}

Headers

X-Dune-Api-Key
string
required

API Key for the service

Query Parameters

api_key
string

Alternative to using the X-Dune-Api-Key header

Body

*/*

ExecuteSQLRequest

sql
string
required

The SQL query to execute

performance
enum<string>

The performance engine tier the execution will be run on

Available options:
medium,
large

Response

OK

execution_id
string
Example:

"01HKZJ2683PHF9Q9PHHQ8FW4Q1"

state
string
Example:

"QUERY_STATE_PENDING"