- Dune API Overview
- API Quickstart
- Authentication
- Client SDKs
- Result Filtering
- Rate Limits
- Troubleshooting Errors
- Billing
- FAQ
Custom Endpoints
SQL Endpoints
- Executions and Results
- Queries
- Materialized Views
- Webhooks
Data Management Endpoints
- Tables
Preset Endpoints
- DEX
- EigenLayer
- EVM Contracts
- Farcaster
- Markets
- Projects
Queries
Create Query
This API allows for anyone to create a query. The owner of the query will be under the context of the API key.
POST
/
v1
/
query
curl --request POST \
--url https://api.dune.com/api/v1/query \
--header 'Content-Type: application/json' \
--header 'X-DUNE-API-KEY: <x-dune-api-key>' \
--data '{
"name": "erc20 balances (user address) API",
"description": "Example Blockchain Query",
"parameters": [
{
"key": "address",
"value": "0x2ae8c972fb2e6c00dded8986e2dc672ed190da06",
"type": "text"
},
{
"key": "blocknumber",
"value": "0",
"type": "number"
},
{
"key": "chain",
"value": "ethereum",
"type": "enum",
"enumOptions": [
"ethereum",
"polygon",
"optimism",
"arbitrum",
"avalanche_c",
"gnosis",
"bnb"
]
}
],
"query_sql": "SELECT * FROM {{blockchain}}.transactions WHERE to = {{address}} AND block_number > {{blocknumber}}",
"is_private": true
}'
{
"query_id": 1
}
To access Query endpoints, a Plus plan or higher is required.
curl --request POST \
--url https://api.dune.com/api/v1/query \
--header 'Content-Type: application/json' \
--header 'X-DUNE-API-KEY: <x-dune-api-key>' \
--data '{
"name": "erc20 balances (user address) API",
"description": "Example Blockchain Query",
"parameters": [
{
"key": "address",
"value": "0x2ae8c972fb2e6c00dded8986e2dc672ed190da06",
"type": "text"
},
{
"key": "blocknumber",
"value": "0",
"type": "number"
},
{
"key": "chain",
"value": "ethereum",
"type": "enum",
"enumOptions": [
"ethereum",
"polygon",
"optimism",
"arbitrum",
"avalanche_c",
"gnosis",
"bnb"
]
}
],
"query_sql": "SELECT * FROM {{blockchain}}.transactions WHERE to = {{address}} AND block_number > {{blocknumber}}",
"is_private": true
}'
Headers
API Key for the service
Query Parameters
API Key, alternative to using the HTTP header X-Dune-Api-Key
Body
*/*
CreateQueryRequest
The body is of type object
.
Response
200
application/json
OK
The response is of type object
.
Was this page helpful?
curl --request POST \
--url https://api.dune.com/api/v1/query \
--header 'Content-Type: application/json' \
--header 'X-DUNE-API-KEY: <x-dune-api-key>' \
--data '{
"name": "erc20 balances (user address) API",
"description": "Example Blockchain Query",
"parameters": [
{
"key": "address",
"value": "0x2ae8c972fb2e6c00dded8986e2dc672ed190da06",
"type": "text"
},
{
"key": "blocknumber",
"value": "0",
"type": "number"
},
{
"key": "chain",
"value": "ethereum",
"type": "enum",
"enumOptions": [
"ethereum",
"polygon",
"optimism",
"arbitrum",
"avalanche_c",
"gnosis",
"bnb"
]
}
],
"query_sql": "SELECT * FROM {{blockchain}}.transactions WHERE to = {{address}} AND block_number > {{blocknumber}}",
"is_private": true
}'
{
"query_id": 1
}