# Dune API reference

> The Dune Data API runs SQL against Dune's indexed blockchain data and returns the result rows. Investigators use it to run saved queries or their own SQL over on-chain activity, then page through the results. Calls go to https://api.dune.com/api/v1 with the key in the X-Dune-Api-Key header. A run…

Source: https://osinttools.io/apis/dune-analytics/ (Markdown view of an OSINTtools.io page; append `.md` to any page URL for this format).

Compiled by OSINTtools.io editors from the vendor's docs, updated Nov 29, 2026. Listing: https://osinttools.io/tools/dune-analytics/

- Base URL: https://api.dune.com/api/v1
- Authentication: API key in the `X-Dune-Api-Key` header. Get a key: https://dune.com/apis?tab=keys An api_key query parameter is also accepted.
- Free tier: a free trial only
- Pricing: Credits
- Rate limits: Not stated in the docs
- Vendor docs: https://docs.dune.com/api-reference/api-overview
- Go SDK: duneapi-client-go, https://github.com/duneanalytics/duneapi-client-go

## Overview

The Dune Data API runs SQL against Dune's indexed blockchain data and returns the result rows. Investigators use it to run saved queries or their own SQL over on-chain activity, then page through the results.

Calls go to `https://api.dune.com/api/v1` with the key in the `X-Dune-Api-Key` header. A run is asynchronous: submit it, poll the status endpoint until `is_execution_finished` is true, then read the results.

Executions use credits based on compute used; metadata endpoints are free. The docs say free access after a trial is view-only and does not include API exports. Other documented areas not covered here: query management, data uploads, materialized views, pipelines and usage.

## Errors

| Status | Meaning |
| --- | --- |
| 400 | Bad request |
| 401 | Unauthorized, such as an invalid API key |
| 402 | Payment required: the request would exceed billing-cycle limits |
| 403 | Forbidden: query archived, unsaved or no permission |
| 404 | Not found |
| 500 | Internal server error |

## Executions

### Run a saved Dune query and get an execution ID.

`POST /query/{query_id}/execute`

- Footprint: passive (the target is not contacted)
- Cost: Credits by compute used

Starts an execution of a saved query. Use the returned execution_id with the status and results endpoints. The docs' cURL sends query_parameters and performance in a JSON body while the OpenAPI spec defines them as query-string parameters.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `query_id` | path | integer | yes | ID of the saved query Example: 1234567 |
| `performance` | query | string | no | Engine tier; engine default if omitted Example: medium One of: small, medium, large |
| `query_parameters` | query | string | no | JSON key-value pairs for the query's parameters; omitted ones use defaults Example: {"param1": 24} |

Response fields:

- `execution_id` (string): ID to poll and fetch results with
- `state` (string): Execution state, e.g. QUERY_STATE_PENDING

```bash
curl -X POST 'https://api.dune.com/api/v1/query/1234567/execute' \
  -H 'X-Dune-Api-Key: YOUR_API_KEY'
```

Example response (200):

```json
{
  "execution_id": "01EXAMPLE0000000000000000",
  "state": "QUERY_STATE_PENDING"
}
```

### Run raw SQL without a saved query.

`POST /sql/execute`

- Footprint: passive (the target is not contacted)
- Cost: Credits by compute used

Executes the SQL you send. In results, query_id is always 0 for arbitrary SQL.

Response fields:

- `execution_id` (string): ID to poll and fetch results with
- `state` (string): Execution state

```bash
curl -X POST 'https://api.dune.com/api/v1/sql/execute' \
  -H 'X-Dune-Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"sql":"SELECT 1","performance":"medium"}'
```

Example response (200):

```json
{
  "execution_id": "01EXAMPLE0000000000000000",
  "state": "QUERY_STATE_PENDING"
}
```

### Check the state of an execution.

`GET /execution/{execution_id}/status`

- Footprint: passive (the target is not contacted)
- Cost: No credit charge

Poll until is_execution_finished is true. execution_cost_credits is the source of truth for cost.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `execution_id` | path | string | yes | ID returned when the execution was submitted Example: 01EXAMPLE0000000000000000 |

Response fields:

- `execution_id` (string): Execution ID
- `query_id` (integer): Query ID
- `state` (string): PENDING, EXECUTING, COMPLETED, COMPLETED_PARTIAL, FAILED, CANCELED or EXPIRED (prefixed QUERY_STATE_)
- `is_execution_finished` (boolean): Whether the state is terminal
- `submitted_at` (string): Submission time
- `expires_at` (string): When the result expires
- `execution_cost_credits` (number): Credits consumed
- `error.message` (string): Error description, on failure
- `result_metadata.column_names` (string[]): Result column names
- `result_metadata.total_row_count` (integer): Rows in the full result

```bash
curl 'https://api.dune.com/api/v1/execution/01EXAMPLE0000000000000000/status' \
  -H 'X-Dune-Api-Key: YOUR_API_KEY'
```

Example response (200):

```json
{
  "execution_id": "01EXAMPLE0000000000000000",
  "query_id": 0,
  "state": "QUERY_STATE_COMPLETED",
  "is_execution_finished": true,
  "execution_cost_credits": 0.5,
  "result_metadata": {
    "column_names": [
      "col"
    ],
    "total_row_count": 1
  }
}
```

## Results

### Read the rows of a finished execution as JSON.

`GET /execution/{execution_id}/results`

- Footprint: passive (the target is not contacted)

Supports paging, column selection, filtering and sorting. Results are stored for 90 days. A result over the 32 GB storage limit is truncated and needs allow_partial_results=true.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `execution_id` | path | string | yes | Execution ID Example: 01EXAMPLE0000000000000000 |
| `limit` | query | integer | no | Maximum rows to return Example: 100 |
| `offset` | query | integer | no | Zero-based row to start from Example: 0 |
| `columns` | query | string | no | Comma-separated columns to return Example: col |
| `filters` | query | string | no | WHERE-style filter; not with sample_count Example: col > 1 |
| `sort_by` | query | string | no | ORDER BY-style expression Example: col desc |
| `allow_partial_results` | query | boolean | no | Allow truncated results Example: true |

Response fields:

- `execution_id` (string): Execution ID
- `state` (string): Execution state
- `is_execution_finished` (boolean): Whether the state is terminal
- `next_offset` (integer): Offset for the next page
- `next_uri` (string): URI of the next page
- `result.rows[]` (object): One object per row, column name to value
- `result.metadata.column_names` (string[]): Column names
- `result.metadata.total_row_count` (integer): Rows in the full result

```bash
curl 'https://api.dune.com/api/v1/execution/01EXAMPLE0000000000000000/results' \
  -H 'X-Dune-Api-Key: YOUR_API_KEY'
```

Example response (200):

```json
{
  "execution_id": "01EXAMPLE0000000000000000",
  "state": "QUERY_STATE_COMPLETED",
  "is_execution_finished": true,
  "result": {
    "rows": [
      {
        "col": 1
      }
    ],
    "metadata": {
      "column_names": [
        "col"
      ],
      "total_row_count": 1
    }
  }
}
```

---

Listings on OSINTtools.io are reviewed by editors and re-verified on a schedule; check pricing and availability on the vendor's site before relying on them, and use OSINT tools only with a lawful basis.
Site index for agents: https://osinttools.io/llms.txt · Full catalog: https://osinttools.io/llms-full.txt · MCP server (Streamable HTTP, no auth): https://osinttools.io/mcp/
