curl -X GET "https://api.dune.com/api/v1/execution/{{execution_id}}/results" -H x-dune-api-key:{{api_key}}
'''
Download Dune Python SDK by running `pip install dune-client`
For more info, visit the GitHub repository: https://github.com/duneanalytics/dune-client/tree/d2195b2a9577e2dcae5d2600cb3eddce20987f38
'''
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()
result = dune.get_execution_results(job_id = '01HM79YYNXADPK66YWZK5X0NXB') # pass in the execution_id
import requests
url = "https://api.dune.com/api/v1/execution/{execution_id}/results"
headers = {"X-DUNE-API-KEY": "<x-dune-api-key>"}
response = requests.request("GET", url, headers=headers)
print(response.text)
const options = {method: 'GET', headers: {'X-DUNE-API-KEY': '<x-dune-api-key>'}};
fetch('https://api.dune.com/api/v1/execution/{execution_id}/results', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.dune.com/api/v1/execution/{execution_id}/results"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-DUNE-API-KEY", "<x-dune-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/execution/{execution_id}/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-DUNE-API-KEY: <x-dune-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.get("https://api.dune.com/api/v1/execution/{execution_id}/results")
.header("X-DUNE-API-KEY", "<x-dune-api-key>")
.asString();
{
"cancelled_at": "2024-12-20T11:04:18.724658237Z",
"error": {
"message": "Error: Line 1:1: mismatched input 'selecdt'",
"metadata": {
"column": 73,
"line": 10
},
"type": "syntax_error"
},
"execution_ended_at": "2024-12-20T11:04:18.724658237Z",
"execution_id": "01HKZJ2683PHF9Q9PHHQ8FW4Q1",
"execution_started_at": "2024-12-20T11:04:18.724658237Z",
"expires_at": "2024-12-20T11:04:18.724658237Z",
"is_execution_finished": true,
"next_offset": 100,
"next_uri": "https://api.dune.com/api/v1/execution/01HKZJ2683PHF9Q9PHHQ8FW4Q1/results?offset=100&limit=100",
"query_id": 1234,
"result": {
"metadata": {
"column_names": [
"Rank",
"Project",
"Volume"
],
"column_types": [
"double",
"varchar",
"bigint"
],
"datapoint_count": 1000,
"execution_time_millis": 1000,
"pending_time_millis": 1000,
"result_set_bytes": 1000,
"row_count": 10,
"total_result_set_bytes": 10000,
"total_row_count": 1000
},
"rows": [
{}
],
"update_type": "<string>"
},
"state": "QUERY_STATE_COMPLETED",
"submitted_at": "2024-12-20T11:04:18.724658237Z"
}{
"error": "Bad Request"
}{
"error": "Invalid API Key"
}{
"error": "This API request would exceed your configured limits per billing cycle."
}{
"error": "Object not found"
}{
"error": "Internal error"
}Executions and Results
Get Execution Result
Returns the result of an execution in JSON format, given the execution ID returned when the query or SQL was submitted for execution. Use the query parameters to page, filter, sort, and sample the result rows.
GET
/
v1
/
execution
/
{execution_id}
/
results
curl -X GET "https://api.dune.com/api/v1/execution/{{execution_id}}/results" -H x-dune-api-key:{{api_key}}
'''
Download Dune Python SDK by running `pip install dune-client`
For more info, visit the GitHub repository: https://github.com/duneanalytics/dune-client/tree/d2195b2a9577e2dcae5d2600cb3eddce20987f38
'''
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()
result = dune.get_execution_results(job_id = '01HM79YYNXADPK66YWZK5X0NXB') # pass in the execution_id
import requests
url = "https://api.dune.com/api/v1/execution/{execution_id}/results"
headers = {"X-DUNE-API-KEY": "<x-dune-api-key>"}
response = requests.request("GET", url, headers=headers)
print(response.text)
const options = {method: 'GET', headers: {'X-DUNE-API-KEY': '<x-dune-api-key>'}};
fetch('https://api.dune.com/api/v1/execution/{execution_id}/results', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.dune.com/api/v1/execution/{execution_id}/results"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-DUNE-API-KEY", "<x-dune-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/execution/{execution_id}/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-DUNE-API-KEY: <x-dune-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.get("https://api.dune.com/api/v1/execution/{execution_id}/results")
.header("X-DUNE-API-KEY", "<x-dune-api-key>")
.asString();
{
"cancelled_at": "2024-12-20T11:04:18.724658237Z",
"error": {
"message": "Error: Line 1:1: mismatched input 'selecdt'",
"metadata": {
"column": 73,
"line": 10
},
"type": "syntax_error"
},
"execution_ended_at": "2024-12-20T11:04:18.724658237Z",
"execution_id": "01HKZJ2683PHF9Q9PHHQ8FW4Q1",
"execution_started_at": "2024-12-20T11:04:18.724658237Z",
"expires_at": "2024-12-20T11:04:18.724658237Z",
"is_execution_finished": true,
"next_offset": 100,
"next_uri": "https://api.dune.com/api/v1/execution/01HKZJ2683PHF9Q9PHHQ8FW4Q1/results?offset=100&limit=100",
"query_id": 1234,
"result": {
"metadata": {
"column_names": [
"Rank",
"Project",
"Volume"
],
"column_types": [
"double",
"varchar",
"bigint"
],
"datapoint_count": 1000,
"execution_time_millis": 1000,
"pending_time_millis": 1000,
"result_set_bytes": 1000,
"row_count": 10,
"total_result_set_bytes": 10000,
"total_row_count": 1000
},
"rows": [
{}
],
"update_type": "<string>"
},
"state": "QUERY_STATE_COMPLETED",
"submitted_at": "2024-12-20T11:04:18.724658237Z"
}{
"error": "Bad Request"
}{
"error": "Invalid API Key"
}{
"error": "This API request would exceed your configured limits per billing cycle."
}{
"error": "Object not found"
}{
"error": "Internal error"
}Minimum required API key scope:
Readexecution_id obtained from making an execute query POST request.
Result returns the status, metadata, and query results (in JSON) from a query execution.
- Read more on Filtering, Sorting, and Sampling to learn more about flexibly grabbing query results.
- Read more on Pagination to get the most out of the API and handle large results.
- Results data from an execution are stored for 90 days. This is visible on the API response on the “expires_at” field in the execution status and results body.
- Dune internally has a maximum query result size limit (which currently is 32GB). If your query yields more than 32GB of data, the result will be truncated in storage. In such cases, pulling the result data (using pagination) but without specifying
allow_partial_resultsset to true will trigger an error message: “error”: “Partial Result, please request with ‘allows_partial_results=true’”. If you wish to retrieve partial results, you can pass the parameterallow_partial_results=true. But please make sure you indeed want to fetch the truncated result.
Execute query and get result in one call
Execute query and get result in one call
If you are using the Python SDK or community Typescript SDK, you can directly execute and fetch a result in one function call, like below:
- Python SDK
- Typescript 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()
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
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")
)
import { QueryParameter, DuneClient } from "@duneanalytics/client-sdk";
const { DUNE_API_KEY } = process.env;
const client = new DuneClient(DUNE_API_KEY ?? "");
refresh to get result in JSONconst queryID = 1215383;
const parameters = [
QueryParameter.text("TextField", "Plain Text"),
QueryParameter.number("NumberField", 3.1415926535),
QueryParameter.date("DateField", "2022-05-04 00:00:00"),
QueryParameter.enum("ListField", "Option 1"),
];
client
.refresh(queryID, parameters)
.then((executionResult) => console.log(executionResult.result?.rows));
// should look like
// [
// {
// date_field: "2022-05-04 00:00:00",
// list_field: "Option 1",
// number_field: "3.1415926535",
// text_field: "Plain Text",
// },
// ];
curl -X GET "https://api.dune.com/api/v1/execution/{{execution_id}}/results" -H x-dune-api-key:{{api_key}}
'''
Download Dune Python SDK by running `pip install dune-client`
For more info, visit the GitHub repository: https://github.com/duneanalytics/dune-client/tree/d2195b2a9577e2dcae5d2600cb3eddce20987f38
'''
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()
result = dune.get_execution_results(job_id = '01HM79YYNXADPK66YWZK5X0NXB') # pass in the execution_id
import requests
url = "https://api.dune.com/api/v1/execution/{execution_id}/results"
headers = {"X-DUNE-API-KEY": "<x-dune-api-key>"}
response = requests.request("GET", url, headers=headers)
print(response.text)
const options = {method: 'GET', headers: {'X-DUNE-API-KEY': '<x-dune-api-key>'}};
fetch('https://api.dune.com/api/v1/execution/{execution_id}/results', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.dune.com/api/v1/execution/{execution_id}/results"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-DUNE-API-KEY", "<x-dune-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/execution/{execution_id}/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-DUNE-API-KEY: <x-dune-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.get("https://api.dune.com/api/v1/execution/{execution_id}/results")
.header("X-DUNE-API-KEY", "<x-dune-api-key>")
.asString();
Query Parameters
Number of rows to return from the result by sampling the data. This is useful when you
want to get a uniform sample instead of the entire result. If the result has less
than the sample count, the entire result is returned. Note that this will return a
randomized sample, so not every call will return the same result. This parameter is
incompatible with offset, limit, and filters parameters.
Response
OK
Was this page helpful?