curl --request GET \
--url https://api.dune.com/api/v1/query/{queryId} \
--header 'X-DUNE-API-KEY: <x-dune-api-key>'
from dune_client.client import DuneClient
dune = DuneClient()
query = dune.get_query(1252207)
import requests
url = "https://api.dune.com/api/v1/query/{queryId}"
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/query/{queryId}', 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/query/{queryId}"
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/query/{queryId}",
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/query/{queryId}")
.header("X-DUNE-API-KEY", "<x-dune-api-key>")
.asString();
{
"contributors": [
{
"contribution_count": 5,
"handle": "wizardofdefi"
}
],
"description": "Calculate the average dex volume",
"is_archived": false,
"is_private": true,
"is_temp": false,
"is_unsaved": false,
"name": "My Query",
"owner": "dune",
"parameters": [
{
"description": "<string>",
"enumFromResults": {
"columnName": "<string>",
"queryId": 123
},
"enumOptions": [
"<string>"
],
"isFreeformAllowed": true,
"isMultiselect": true,
"key": "<string>",
"type": "<string>",
"value": "<string>",
"values": [
"<string>"
]
}
],
"query_engine": "medium",
"query_id": 123,
"query_sql": "SELECT * FROM dex.trades",
"tags": [
"<string>"
],
"version": 1
}{
"error": "Bad Request"
}{
"error": "Invalid API Key"
}{
"error": "Not allowed to execute query. Query is archived, unsaved or not enough permissions"
}{
"error": "Object not found"
}{
"error": "Internal error"
}Query Management
Read Query
This API allows for anyone to read the sql text, parameters, name, tags, and state of a query. For private queries, only the API key generated under the context of the owner of that query will work.
GET
/
v1
/
query
/
{queryId}
curl --request GET \
--url https://api.dune.com/api/v1/query/{queryId} \
--header 'X-DUNE-API-KEY: <x-dune-api-key>'
from dune_client.client import DuneClient
dune = DuneClient()
query = dune.get_query(1252207)
import requests
url = "https://api.dune.com/api/v1/query/{queryId}"
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/query/{queryId}', 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/query/{queryId}"
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/query/{queryId}",
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/query/{queryId}")
.header("X-DUNE-API-KEY", "<x-dune-api-key>")
.asString();
{
"contributors": [
{
"contribution_count": 5,
"handle": "wizardofdefi"
}
],
"description": "Calculate the average dex volume",
"is_archived": false,
"is_private": true,
"is_temp": false,
"is_unsaved": false,
"name": "My Query",
"owner": "dune",
"parameters": [
{
"description": "<string>",
"enumFromResults": {
"columnName": "<string>",
"queryId": 123
},
"enumOptions": [
"<string>"
],
"isFreeformAllowed": true,
"isMultiselect": true,
"key": "<string>",
"type": "<string>",
"value": "<string>",
"values": [
"<string>"
]
}
],
"query_engine": "medium",
"query_id": 123,
"query_sql": "SELECT * FROM dex.trades",
"tags": [
"<string>"
],
"version": 1
}{
"error": "Bad Request"
}{
"error": "Invalid API Key"
}{
"error": "Not allowed to execute query. Query is archived, unsaved or not enough permissions"
}{
"error": "Object not found"
}{
"error": "Internal error"
}Minimum required API key scope:
ReadTo access Query endpoints, an Analyst plan or higher is required.
curl --request GET \
--url https://api.dune.com/api/v1/query/{queryId} \
--header 'X-DUNE-API-KEY: <x-dune-api-key>'
from dune_client.client import DuneClient
dune = DuneClient()
query = dune.get_query(1252207)
import requests
url = "https://api.dune.com/api/v1/query/{queryId}"
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/query/{queryId}', 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/query/{queryId}"
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/query/{queryId}",
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/query/{queryId}")
.header("X-DUNE-API-KEY", "<x-dune-api-key>")
.asString();
Response
OK
Was this page helpful?