Skip to main content
This guide will walk you through everything you need to get started with Dune’s APIs, from creating an API key to making your first request.

1. Sign Up

Create your account at dune.com/auth/register New accounts come with free credits to get you started.

2. Generate API Key

  1. Navigate to API settings page
  2. Click Create API Key
  3. Give your key a descriptive name (e.g., “Production API”, “Development”)
  4. Copy and securely store your API key
  • Dune has two types of account: user account and team account. A team can have many users. A user can join many teams.
  • Each user or team account has its own context. Queries created under a team account can only be managed within the team account context.
  • An API key belongs to a specific context, and is either associated with a user account or a team account.
Keep your API key secure! Treat it like a password. Never commit it to version control or share it publicly. Anyone with your API key can make requests on your behalf and consume your credits.

3. Authenticate

Use your API key to authenticate requests to Dune’s APIs. Include it in your request headers:
X-DUNE-API-KEY: your-api-key-here

Initialize the SDK

from dune_client import DuneClient

# DuneClient will read the DUNE_API_KEY environment variable
dune = DuneClient()
Best practices:
  • Store API keys in environment variables
  • Create separate keys for development and production
  • Rotate keys periodically
  • Revoke keys immediately if compromised

4. Get Started

Use your API key to make requests to Dune’s APIs. Here’s a simple example to get recent DEX trades:
# Execute a SQL query
curl -X POST "https://api.dune.com/api/v1/sql/execute" \
  -H "Content-Type: application/json" \
  -H "X-DUNE-API-KEY: YOUR_API_KEY" \
  -d '{
    "sql": "SELECT * FROM dex.trades WHERE block_time > now() - interval '\''1'\'' day LIMIT 10",
    "performance": "medium"
  }'

Understanding the Response

The API returns an execution object with your query status:
{
  "execution_id": "01K9AHMWSJZD59KAGB3WY45895",
  "state": "QUERY_STATE_EXECUTING",
  "submitted_at": "2025-11-05T17:39:48.146829Z",
  "expires_at": "2026-02-03T17:39:48.329665Z"
}
Queries execute asynchronously. Use the execution_id to check status and retrieve results. Our SDKs handle polling automatically.

Getting Results

Once execution completes, fetch the results:
curl "https://api.dune.com/api/v1/execution/{execution_id}/results" \
  -H "X-DUNE-API-KEY: YOUR_API_KEY"

Next Steps

Now that you’ve made your first request, explore common use cases:

Analyze onchain data

Build custom analytics pipelines and reports

Use connectors

Connect with Trino Connector or DBT Connector for maximum flexibility

Additional Resources

API Reference

Complete endpoint documentation

Rate Limits

Understand API rate limits

Troubleshooting

Common issues and solutions

Getting Help

Community Discord

Get help from the Dune community

Support

Contact our support team

Status Page

Check API status and uptime