Skip to main content
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"
}