Skip to main content
If you are using the Python SDK, you can directly execute and fetch result in one function call, like below:
Use run_query to get result in JSON, run_query_csv to get result in CSV format, and run_query_dataframe to get result in Pandas dataframe
Python SDK

import json
from dune_client.types import QueryParameter
from dune_client.client import DuneClient
from dune_client.query import QueryBase

# setup Dune Python client
dune = DuneClient()

query = QueryBase(
    name="Sample Query",
    query_id=1215383,
)

result = dune.run_query(
    query = query,
    performance = 'large' # optionally define which tier to run the execution on (default is "medium")
)

# go over the results returned
for row in result.result.rows: 
    print (row) # as an example we print the rows
If the query has parameters and you don’t add them in your API call, it will just run with the default params. You may add query parameters as part of the POST params data. You can choose to include a performance parameter, by default it will use the “medium” performance tier. Credits are consumed based on actual compute resources used. “large” tier provides more resources for complex queries. Returns an execution_id associated with the triggered query execution and the state of the execution.
curl -X POST "https://api.dune.com/api/v1/query/{{query_id}}/execute"   \
  -H "X-Dune-API-Key: {{api_key}}"                                       \
  -H "Content-Type: application/json"                                   \
  -d '{"query_parameters": {"param1":24}, "performance": "large"}'