> ## Documentation Index
> Fetch the complete documentation index at: https://lava.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Dune

> Onchain SQL analytics platform for querying blockchain data across Ethereum, Polygon, Arbitrum, and other chains.

Onchain SQL analytics platform for querying blockchain data across Ethereum, Polygon, Arbitrum, and other chains. Use for on-chain analysis like token holder counts, DeFi protocol TVL, or transaction patterns. Supports both saved queries (by ID) and raw SQL execution — raw SQL is more flexible but requires knowing the table schema.

13 endpoints available through Lava's AI Gateway. See the [Dune API docs](https://docs.dune.com/api-reference/overview/introduction) for full documentation.

<Info>Supports both **managed** (Lava's API keys) and **unmanaged** (bring your own credentials) mode.</Info>

## Endpoints

### Execute a saved query by ID

**POST** `https://api.dune.com/api/v1/query/3237721/execute` — \$0.005 / request

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://api.dune.com/api/v1/query/3237721/execute', { body: {"query_parameters":{}} });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.lava.so/v1/forward?u=https%3A%2F%2Fapi.dune.com%2Fapi%2Fv1%2Fquery%2F3237721%2Fexecute" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{"query_parameters":{}}'
    ```
  </Tab>
</Tabs>

### Execute raw SQL query

**POST** `https://api.dune.com/api/v1/sql/execute` — \$0.005 / request

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://api.dune.com/api/v1/sql/execute', { body: {"sql":"SELECT 1"} });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.lava.so/v1/forward?u=https%3A%2F%2Fapi.dune.com%2Fapi%2Fv1%2Fsql%2Fexecute" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{"sql":"SELECT 1"}'
    ```
  </Tab>
</Tabs>

### Get query execution results

**GET** `https://api.dune.com/api/v1/query/3237721/results` — \$0.005 / request

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://api.dune.com/api/v1/query/3237721/results', { method: 'GET' });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.lava.so/v1/forward?u=https%3A%2F%2Fapi.dune.com%2Fapi%2Fv1%2Fquery%2F3237721%2Fresults" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY"
    ```
  </Tab>
</Tabs>

### Get query results as CSV

**GET** `https://api.dune.com/api/v1/query/{id}/results/csv` — \$0.005 / request

### Check execution status

**GET** `https://api.dune.com/api/v1/execution/{id}/status` — \$0.005 / request

### Get execution results by ID

**GET** `https://api.dune.com/api/v1/execution/{id}/results` — \$0.005 / request

### Get execution results as CSV

**GET** `https://api.dune.com/api/v1/execution/{id}/results/csv` — \$0.005 / request

### List available datasets

**GET** `https://api.dune.com/api/v1/datasets` — \$0.005 / request

### Get dataset details

**GET** `https://api.dune.com/api/v1/datasets/{id}` — \$0.005 / request

### Execute a query pipeline

**POST** `https://api.dune.com/api/v1/query/{id}/pipeline/execute` — \$0.005 / request

### Execute a pipeline

**POST** `https://api.dune.com/api/v1/pipelines/execute` — \$0.005 / request

### Check pipeline execution status

**GET** `https://api.dune.com/api/v1/pipelines/executions/{id}/status` — \$0.005 / request

### Get query pipeline configuration

**GET** `https://api.dune.com/api/v1/query/{id}/pipeline` — \$0.005 / request

## Next Steps

<CardGroup cols={2}>
  <Card title="All Providers" icon="grid" href="/gateway/supported-providers">
    Browse all supported AI providers
  </Card>

  <Card title="Forward Proxy" icon="route" href="/gateway/forward-proxy">
    Learn how to construct proxy URLs and authenticate requests
  </Card>
</CardGroup>
