Get query pipeline
curl --request GET \
--url https://api.dune.com/api/v1/query/{query_id}/pipeline \
--header 'X-Dune-Api-Key: <x-dune-api-key>'import requests
url = "https://api.dune.com/api/v1/query/{query_id}/pipeline"
headers = {"X-Dune-Api-Key": "<x-dune-api-key>"}
response = requests.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/{query_id}/pipeline', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/query/{query_id}/pipeline",
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;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.dune.com/api/v1/query/{query_id}/pipeline"
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, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.dune.com/api/v1/query/{query_id}/pipeline")
.header("X-Dune-Api-Key", "<x-dune-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dune.com/api/v1/query/{query_id}/pipeline")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Dune-Api-Key"] = '<x-dune-api-key>'
response = http.request(request)
puts response.read_body{
"pipeline": {
"nodes": [
{
"dependencies": [
123
],
"id": 1,
"materialized_view_refresh": {
"name": "mv_1",
"performance": "medium"
},
"query_execution": {
"performance": "medium",
"query_id": 1234,
"query_parameters": {}
}
}
]
}
}{
"error": "Bad Request"
}{
"error": "Invalid API Key"
}{
"error": "Object not found"
}{
"error": "Internal error"
}Query Management
Get Query Pipeline
Builds a query pipeline from the specified query and returns the pipeline definition containing all the nested materialized views that the query depends on. A pipeline allows you to chain multiple queries together and execute them as a single unit.
GET
/
v1
/
query
/
{query_id}
/
pipeline
Get query pipeline
curl --request GET \
--url https://api.dune.com/api/v1/query/{query_id}/pipeline \
--header 'X-Dune-Api-Key: <x-dune-api-key>'import requests
url = "https://api.dune.com/api/v1/query/{query_id}/pipeline"
headers = {"X-Dune-Api-Key": "<x-dune-api-key>"}
response = requests.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/{query_id}/pipeline', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dune.com/api/v1/query/{query_id}/pipeline",
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;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.dune.com/api/v1/query/{query_id}/pipeline"
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, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.dune.com/api/v1/query/{query_id}/pipeline")
.header("X-Dune-Api-Key", "<x-dune-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dune.com/api/v1/query/{query_id}/pipeline")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Dune-Api-Key"] = '<x-dune-api-key>'
response = http.request(request)
puts response.read_body{
"pipeline": {
"nodes": [
{
"dependencies": [
123
],
"id": 1,
"materialized_view_refresh": {
"name": "mv_1",
"performance": "medium"
},
"query_execution": {
"performance": "medium",
"query_id": 1234,
"query_parameters": {}
}
}
]
}
}{
"error": "Bad Request"
}{
"error": "Invalid API Key"
}{
"error": "Object not found"
}{
"error": "Internal error"
}Minimum required API key scope:
ReadOverview
This endpoint returns the pipeline structure that would be executed for a given query, allowing you to inspect the lineage and execution order before running the pipeline. This is useful for understanding dependencies and planning pipeline executions. The pipeline definition contains all the nodes (queries and materialized view refreshes) in the correct dependency order.The
query_parameters should be passed as a URL-encoded JSON string in the query parameter, where keys are parameter names and values are parameter values.Use Cases
Inspect Pipeline Before Execution
Check what queries and materialized views will be executed:curl "https://api.dune.com/api/v1/query/3493826/pipeline?performance=medium" \
-H "X-Dune-Api-Key: $DUNE_API_KEY"
Validate Dependencies with Parameters
Understand query dependencies before running a pipeline with specific parameters:# Query parameters as JSON string
curl "https://api.dune.com/api/v1/query/3493826/pipeline?performance=large&query_parameters=%7B%22blockchain%22%3A%22ethereum%22%7D" \
-H "X-Dune-Api-Key: $DUNE_API_KEY"
Response Structure
The response contains apipeline object with a nodes array. Each node represents either a query execution or materialized view refresh, along with its dependencies.
Example response:
{
"pipeline": {
"nodes": [
{
"id": 1,
"dependencies": [],
"materialized_view_refresh": {
"name": "dune.analyst.mv_base_data",
"performance": "medium"
}
},
{
"id": 2,
"dependencies": [1],
"query_execution": {
"query_id": 3493826,
"performance": "medium"
}
}
]
}
}
Best Practices
Use Before Pipeline Execution
Use Before Pipeline Execution
Call this endpoint before executing a pipeline to understand what will be executed and in what order. This helps with planning and cost estimation.
Validate Complex Dependencies
Validate Complex Dependencies
For queries with many dependencies, use this endpoint to visualize the execution graph and identify potential bottlenecks.
Test with Parameters
Test with Parameters
When using query parameters, test the pipeline structure with different parameter values to ensure the lineage is resolved correctly.
Related Endpoints
- Execute Query Pipeline - Execute a query’s pipeline
- Execute Pipeline - Execute a pipeline based on lineage
- Get Pipeline Status - Check pipeline execution status
Headers
API Key for the service
Path Parameters
Unique identifier of the query
Query Parameters
Alternative to using the X-Dune-Api-Key header
The performance engine tier. Can be small, medium, or large.
SQL Query parameters in json key-value pairs
Response
OK
The pipeline definition containing nodes to execute
Show child attributes
Show child attributes
Was this page helpful?