SDKs overview

Dune offers Software Development Kits (SDKs) and libraries that facilitate programmatic interaction with its on-chain data analytics platform. These tools are designed for developers who need to integrate Dune's data querying capabilities into their applications, automate data extraction, or manage their dashboards and queries without direct web interface interaction. The primary method for accessing Dune's data programmatically is through its API, which is typically wrapped by these SDKs to provide a more convenient and idiomatic interface for specific programming languages. Access to the Dune API, and thus full utilization of certain SDK features, is generally available on paid subscription tiers, such as the Dune Plus plan or Enterprise offerings.

The SDKs allow users to perform operations such as executing SQL queries against Dune's extensive datasets, retrieving the results of those queries, and interacting with existing dashboards. This capability is particularly useful for building custom analytics tools, integrating blockchain data into financial models, or creating automated reporting systems. While Dune's core experience is centered around its web-based SQL editor and visualization tools, the availability of SDKs extends its utility to a broader range of development workflows and integration scenarios.

Developers who leverage the SDKs can streamline their data pipelines, ensuring that their applications always have access to the latest on-chain information processed by Dune. This integration can significantly reduce manual effort in data collection and preparation, allowing teams to focus on analysis and application development. The design philosophy behind these SDKs often mirrors the structure of common API interaction patterns, providing methods for authentication, request parameterization, and response parsing.

Official SDKs by language

Dune provides official SDKs to enable developers to interact with its platform using popular programming languages. These SDKs are maintained by Dune and offer stable interfaces for accessing the Dune API. The primary official SDK is available for Python, reflecting Python's prevalence in data science and analytics workflows.

The official SDKs generally cover key functionalities such as:

  • Query execution: Submitting SQL queries to Dune's engine.
  • Result retrieval: Fetching the data output from executed queries.
  • Query status monitoring: Checking the progress and completion of asynchronous queries.
  • Parameter handling: Passing dynamic parameters to parameterized queries.

Below is a summary of the official SDKs:

Language Package/Module Install Command Maturity
Python dune-client pip install dune-client Stable
JavaScript/TypeScript @duneanalytics/client npm install @duneanalytics/client Stable

These SDKs are designed to abstract away the complexities of direct HTTP requests to the Dune API, providing a more intuitive and Pythonic or JavaScript-native way to interact with the platform. For example, the Python dune-client library allows developers to instantiate a client object, pass an API key, and then call methods like execute_query or get_query_results, simplifying the process of programmatic data access as detailed in the Dune Python Client documentation.

The choice of Python as the primary language for an official SDK aligns with the typical use cases for blockchain data analysis, where Python's extensive libraries for data manipulation, scientific computing, and visualization (e.g., Pandas, NumPy, Matplotlib) are frequently employed. This makes it easier for data scientists and analysts to integrate Dune data directly into their existing data processing pipelines and analytical scripts.

Installation

Installing Dune's official SDKs typically involves using standard package managers for their respective programming environments. The process is straightforward, ensuring developers can quickly set up their development environment to begin interacting with the Dune API.

Python SDK (dune-client)

The Python client library can be installed using pip, the Python package installer. It is recommended to use a virtual environment to manage dependencies.

python3 -m venv dune_env
source dune_env/bin/activate  # On Windows, use `dune_env\Scripts\activate`
pip install dune-client

After installation, you can verify the package is installed by attempting to import it in a Python interpreter:

import dune_client
print(dune_client.__version__)

This will display the installed version of the dune-client library. For more detailed instructions and troubleshooting, refer to the official Dune Python client guide.

JavaScript/TypeScript SDK (@duneanalytics/client)

For JavaScript and TypeScript projects, the official client library is available via npm or yarn.

npm install @duneanalytics/client
# or
yarn add @duneanalytics/client

Once installed, you can import and use the client in your JavaScript or TypeScript applications:

import { DuneClient } from '@duneanalytics/client';
// Or for CommonJS:
// const { DuneClient } = require('@duneanalytics/client');

console.log('Dune client installed successfully');

This setup allows developers to integrate Dune's capabilities into web applications, server-side Node.js scripts, or other JavaScript-based environments. The use of TypeScript in the package also provides type safety for developers working with TypeScript projects, enhancing the developer experience by offering autocompletion and compile-time error checking. Further details on the JavaScript client can be found in the Dune JavaScript client documentation.

Quickstart example

This quickstart demonstrates how to use the Dune Python SDK to execute a query and fetch its results. This example assumes you have an API key and a query ID available. API keys are obtained from your Dune account settings, typically requiring a paid plan for full API access, as mentioned on the Dune pricing page.

Prerequisites

  • Python 3.7+ installed
  • dune-client installed (pip install dune-client)
  • A Dune API Key (available from your Dune settings)
  • A Query ID from a public or private query on Dune

Python Quickstart Code

This script will execute a specified query and print the first few rows of its results.

import os
from dune_client.client import DuneClient
from dune_client.types import QueryParameter
from dune_client.query import Query

# --- Configuration ---
# Replace with your actual Dune API Key
DUNE_API_KEY = os.environ.get("DUNE_API_KEY", "YOUR_API_KEY_HERE")

# Replace with the ID of a Dune query you want to execute
# Example: Query ID for a simple ETH price query might be 1234567
# Find query IDs in the URL of your Dune query page: dune.com/queries/{query_id}
QUERY_ID = 1234567 # Replace with an actual query ID

# Optional: Define query parameters if your query uses them
# For example, a query might take a 'start_date' parameter.
# query_parameters = [
#     QueryParameter.text_type(key="StartDate", value="2023-01-01"),
#     QueryParameter.number_type(key="Limit", value=100)
# ]
query_parameters = []

# --- Initialize Dune Client ---
print("Initializing Dune Client...")
dune = DuneClient(DUNE_API_KEY)

# --- Define the Query ---
query = Query(
    query_id=QUERY_ID,
    params=query_parameters,
)

# --- Execute the Query ---
print(f"Executing query ID: {QUERY_ID}...")
try:
    # `run_query` returns results directly if query is cached or runs and waits
    results = dune.run_query(query)
    print("Query executed successfully.")

    # --- Process Results ---
    if results and results.result.rows:
        print(f"Fetched {len(results.result.rows)} rows.")
        print("First 5 rows:")
        for i, row in enumerate(results.result.rows[:5]):
            print(f"Row {i+1}: {row}")
    else:
        print("No results returned or query took too long to execute.")

except Exception as e:
    print(f"An error occurred during query execution: {e}")

To run this code:

  1. Save the code as a Python file (e.g., dune_quickstart.py).
  2. Replace "YOUR_API_KEY_HERE" with your actual Dune API key, or set it as an environment variable DUNE_API_KEY.
  3. Replace 1234567 with a valid Query ID from your Dune dashboard.
  4. Execute the script from your terminal: python dune_quickstart.py.

This example demonstrates the basic flow: client initialization, query definition, execution, and result processing. For more advanced features, such as asynchronous query management, tracking query status, or accessing specific result formats, consult the Dune Python client documentation.

Community libraries

Beyond the officially supported SDKs, the Dune ecosystem benefits from community-contributed libraries and tools. These libraries often extend functionality, offer integrations with other platforms, or provide clients in languages not officially supported by Dune. While not maintained by Dune, these community projects can offer valuable alternatives or specialized features for specific use cases.

When considering community libraries, it is important to evaluate their maintenance status, documentation, and community support, as these can vary significantly compared to official SDKs. Developers should review the source code and issue trackers to assess reliability and ongoing development.

Examples of Community Contributions (as of 2026-05-29):

  • Dune API Go Client (e.g., dune-api-go): While not official, several open-source Go clients exist that wrap the Dune API, allowing Go developers to integrate Dune data into their applications. These typically mirror the functionality of fetching query results and executing queries. An example of a community-driven Go client might be found on platforms like GitHub, developed by independent contributors.
  • Data Visualization Integrations: Community efforts often focus on integrating Dune data with popular data visualization tools or dashboards outside of Dune's native capabilities. This could include connectors for business intelligence tools or custom charting libraries.
  • Specialized Data Fetchers: Some community libraries might specialize in fetching specific types of data, such as NFT floor prices or DeFi protocol metrics, by abstracting common Dune queries into simpler function calls.

To find the latest community-contributed libraries, developers typically explore platforms like GitHub, PyPI (for Python), or npm (for JavaScript), searching for packages related to "Dune Analytics" or "Dune API." Checking the Dune documentation or community forums can also sometimes point to widely used or recommended third-party tools. For instance, discussions on blockchain data analysis tools often surface various open-source projects, similar to how developers discover general API client libraries for other services.

It is good practice to review the license of any community library before incorporating it into a project to ensure compatibility with your project's licensing requirements. Additionally, regularly checking for updates is crucial, as community projects may evolve at a different pace than official releases.