- Dune API Overview
API Quickstart
- Authentication
- Client SDKs
Result Filtering
- Rate Limits
- Troubleshooting Errors
- Billing
- FAQ
Executions and Results
Queries
Webhooks
Blockchains
Tables
Account APIs
DEX
EigenLayer
EVM Contracts
Farcaster
Markets
Projects
SQL Endpoints
Data Management Endpoints
Realtime Endpoints (Beta)
Preset Endpoints
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.
API Key for the service
API Key for the service, alternative to using the HTTP header X-DUNE-API-KEY.
Name of the query.
Description of the query.
The SQL query text.
Indicates if the query is private.
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": 1616880
}
To access Query endpoints, a Plus plan or higher is required.
Headers
API Key for the service
Query Parameters
API Key for the service, alternative to using the HTTP header X-DUNE-API-KEY.
Body
Name of the query.
Description of the query.
The key name of the parameter.
A brief description of the parameter.
The default value used by this parameter during execution, format depends on the type.
An array of string values, used when multiple selections are allowed.
The type of the parameter, determines the format of 'value(s)'. 'number': Numeric parameters, the value must be a number (e.g., '20'). 'text': String parameters, value can be any text including hex 0x-prefixed values (e.g., '0xae2fc...'), an empty value defaults to an empty string. 'datetime': Date and time parameters, value must be in 'YYYY-MM-DD hh:mm:ss' format (e.g., '2021-12-31 23:59:59'). 'enum': Parameters with a specific list of values, 'EnumValues' field is mandatory, providing a JSON list of strings representing valid options, the 'value' must be one of these options (e.g., 'Option1').
number
, text
, datetime
, enum
List of valid options for 'enum' type parameters.
Indicates if multiple selections are allowed for this parameter.
Indicates if freeform input is allowed for this parameter.
The ID of the query to fetch results from.
The column name to use from the query results.
The SQL query text.
Indicates if the query is private.
Response
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": 1616880
}