curl --request GET \ --url https://api.dune.com/api/v1/query/{query_id}/results/csv
Query Execution and Results
Get Latest Query Result in CSV
Given a query ID, returns the latest executed result of a query on Dune in CSV format
You must pass parameter query_id.Returns the latest execution id and results (in CSV) of that latest run, regardless of the job id/run or if it is run in the app or the api.The query specified must either be public or a query you have ownership of (you or a team you belong to have ownership).
There is currently a 1GB limit in how much data a single API result call can return, but there is a chance we reduce this overall or based on varying paid plan types.
Execute query and get result in one call
If you are using the Python SDK, you can directly executes and fetches result in one function call, like below:
Python SDK
Copy
Ask AI
import dotenv, os, jsonfrom dune_client.types import QueryParameterfrom dune_client.client import DuneClientfrom dune_client.query import QueryBase# change the current working directory where .env file livesos.chdir("/Users/abc/local-Workspace/python-notebook-examples")# load .env filedotenv.load_dotenv(".env")# setup Dune Python clientdune = DuneClient.from_env()
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
Copy
Ask AI
result = dune.run_query( query=query # pass in query to run , performance = 'large' # optionally define which tier to run the execution on (default is "medium") )
Copy
Ask AI
curl --request GET \ --url https://api.dune.com/api/v1/query/{query_id}/results/csv