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.

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

performance
enum<string>

The performance engine tier the execution will be run on. Can be either medium or large. Credits are consumed based on actual compute resources used. Medium is the default, large provides more resources for complex queries.

Available options:
medium,
large

Body

*/* · string

Raw SQL query to execute

The body is of type string.

Response

OK

execution_id
string
Example:

"01HKZJ2683PHF9Q9PHHQ8FW4Q1"

state
string
Example:

"QUERY_STATE_PENDING"