Blockchain Data API - Dune SQL Query Results, Onchain Analytics avatar

Blockchain Data API - Dune SQL Query Results, Onchain Analytics

Pricing

$5.00 / 1,000 query result row returneds

Go to Apify Store
Blockchain Data API - Dune SQL Query Results, Onchain Analytics

Blockchain Data API - Dune SQL Query Results, Onchain Analytics

Export Dune query results to a dataset: latest results of any public or owned Dune query, run saved queries with parameters or raw DuneSQL and poll to completion, with filters, sorting and sampling. DEX trades, NFTs, tokens, wallets on Ethereum, Solana, Base and more. Bring your own API key.

Pricing

$5.00 / 1,000 query result row returneds

Rating

0.0

(0)

Developer

Nabeel Hassan

Nabeel Hassan

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

14 days ago

Last modified

Share

Export the results of any public or owned Dune query, or run your own DuneSQL over Dune's indexed blockchain data, straight into an Apify dataset with your own Dune API key.

This actor works with the Dune API (the SQL query execution and results endpoints). It reads the latest stored result of saved Dune queries without re-running them, or executes saved queries with your parameter values and raw DuneSQL statements, polls each execution until it finishes (with a timeout cap), and turns every result row into a clean dataset row you can download as JSON, CSV or Excel, schedule, or feed into dashboards, spreadsheets, trading research, notebooks and AI agents. Bring your own API key.

What it does

  • Latest query results (default, cheapest): reads the newest stored result of each saved Dune query ID, whether it last ran in the Dune app, on a schedule or through the API. Nothing is executed, so no execution credits are used; Dune bills only the data exported.
  • Execute a saved query with parameters: runs each query ID again with the parameter values you give (blockchain, token address, wallet, date range, days and so on), polls the free status endpoint, and reads the result when it completes.
  • Execute raw DuneSQL: runs one SQL statement over Dune tables such as dex.trades, nft.trades, tokens.transfers, prices.usd, decoded contract events and the raw blocks, transactions and logs of Ethereum, Solana, Bitcoin, Base, Arbitrum, Optimism, Polygon, BNB Chain and many more chains.
  • Timeout cap and cancel: an execution still running at your timeout (default 300 seconds, at most 1800) is cancelled so it stops using compute, or left running so you can read it later by execution ID.
  • Stored execution results: re-reads the result of an earlier execution ID (kept by Dune for 90 days) without running anything.
  • Custom endpoints: reads a Dune custom API endpoint by handle and slug.
  • Server-side shaping: filters (a SQL-like WHERE clause), sort (ORDER BY), column selection and uniform random sampling, all applied by Dune before export so you pay for fewer bytes.
  • Credit aware: each read asks only for the rows still left under your maximum, pages by offset, and executions only happen in the execute modes.
  • Pay only for results: empty results, failed or timed out executions and refusals are a free row that says why, never charged.

Input

FieldUsed byWhat it does
modealllatestResult (default), executeQuery, executeSql, executionResult or customEndpoint
queryIdslatest result, execute querySaved Dune query IDs or dune.com/queries URLs, one per line (up to 50, or 10 for executions)
queryParameterslatest result, execute queryJSON object of the query's parameter values, such as {"blockchain": "ethereum"}; a list is a multi-select
sqlexecute SQLOne DuneSQL statement
performanceexecute modesEngine tier: small, medium or large; empty for Dune's default
timeoutSecondsexecute modesHow long to wait for an execution (default 300, max 1800)
pollIntervalSecondsexecute modesHow often to check the status (default 5); status checks are free
cancelOnTimeoutexecute modesCancel an execution still running at the timeout (default on)
executionIdsexecution resultEarlier execution IDs, one per line
customEndpointscustom endpointCustom endpoints as handle/endpoint-slug
filtersallServer-side filter, such as amount_usd > 1000 AND project = 'uniswap'
sortByallServer-side sort, such as amount_usd desc, block_time
columnsallOnly these result columns
sampleCountallA uniform random sample of this many rows (not with filters)
allowPartialResultsallRead a result Dune truncated for size instead of refusing it
maxResultsallRow ceiling for the run (default 100)
requestsPerMinuteallPacing to your plan's rate limit (default 30)
apiKeyallYour Dune API key, stored as a secret

Example input, the latest stored result of a saved query, largest rows first:

{
"mode": "latestResult",
"queryIds": ["3568055"],
"sortBy": "one_day_volume desc",
"maxResults": 100
}

Example input, run raw DuneSQL and wait up to five minutes:

{
"mode": "executeSql",
"sql": "SELECT block_time, blockchain, project, amount_usd, tx_hash FROM dex.trades WHERE block_time > now() - interval '1' hour ORDER BY amount_usd DESC LIMIT 100",
"performance": "medium",
"timeoutSeconds": 300
}

How to get an API key

Sign in at dune.com and create a key under the API keys section of your settings (dune.com/settings/api). API access needs an active trial or a paid Dune plan (Analyst, Plus or Enterprise); free access after a trial is view only and does not include API exports. Bring your own API key: paste it into the API key field or set the DATA_API_KEY environment secret.

Example output

{
"mode": "latestResult",
"modeLabel": "Latest query result",
"recordType": "resultRow",
"identifier": "query 3568055",
"found": true,
"id": "01HW6N7VF1H7VYQ91GC0NP673E|0",
"queryId": "3568055",
"executionId": "01HW6N7VF1H7VYQ91GC0NP673E",
"state": "QUERY_STATE_COMPLETED",
"rowNumber": 0,
"executionEndedAt": "2026-10-10T23:39:29.389539Z",
"expiresAt": "2027-01-08T23:39:29.38954Z",
"executionCostCredits": null,
"totalRowCount": 1000,
"columnNames": ["chain", "all_time_volume", "one_day_volume"],
"chain": "ethereum",
"all_time_volume": 332594074340.38,
"one_day_volume": 92699347.48,
"retrievedAt": "2026-10-11T09:00:00.000Z",
"note": null
}

Every column the query returns becomes its own field, named as in the query; a column that shares a name with one of the actor's own fields is kept as column_<name>. Rows from the execute modes also carry executionCostCredits, the credits Dune reports for that execution.

FAQ

What is the Dune API?

Dune is an onchain data platform that indexes and decodes blockchain data from Ethereum, Solana, Bitcoin, Base, Arbitrum, Optimism, Polygon, BNB Chain and many other chains into SQL tables. The Dune API runs DuneSQL queries and returns their results as JSON, which this actor turns into dataset rows.

Do I need my own API key?

Yes. This actor reads the Dune API with your own key and never ships a shared one. A run without a key ends straight away with a message that says where to get one, and nothing is charged.

Does reading a query's latest result run the query again?

No. The latest query result mode reads the result Dune already stored from the query's last run, in the app, on a schedule or through the API. It uses no execution credits; Dune bills only the data exported. To refresh the data, schedule the query on dune.com or use the execute query mode.

How do I run a Dune query with parameters?

Use the execute query mode, give the query ID and a queryParameters object such as {"token_address": "0x...", "days": 30}. Parameters you leave out keep the defaults set on the query. The actor polls the execution and reads the result when it completes.

Can I run my own SQL?

Yes. The execute SQL mode runs one DuneSQL statement over any Dune table, such as dex.trades, nft.trades, tokens.transfers or decoded contract events. Add a LIMIT to keep compute and export credits down.

What happens if a query takes too long?

The actor waits up to your execution timeout (default 300 seconds, at most 30 minutes, which is Dune's own limit). If the execution is still running, it is cancelled to stop further compute, or, with cancel on timeout off, left running so you can read it later with the execution result mode and the execution ID from the note.

How do I filter or sort results without editing the query?

Set filters (a SQL-like WHERE clause such as amount_usd > 1000), sortBy (an ORDER BY clause such as block_time desc) and columns. Dune applies them server side before export, so smaller results also cost fewer credits.

What do I pay?

Pay per result: 0.005 USD per result row pushed to the dataset. Empty results, failed or timed out executions and refusals are never charged. Your Dune plan's own credits are used separately: executions by compute, and every results read by the megabytes exported, which is why each read asks only for the rows still left under your maximum.

What happens if my key is wrong or my credits run out?

A rejected key (HTTP 401) or a request over your billing cycle's credit limit (HTTP 402) ends the run cleanly with a status message that explains what to change. Rate limits (HTTP 429) are waited out and retried. A private or missing query becomes a free row saying so, and the run moves on.

Keyword map

Dune API, Dune Analytics API, DuneSQL API, blockchain data API, onchain data API, onchain analytics, crypto SQL API, Ethereum data export, Solana onchain data, DEX trades API, NFT trades data, token transfers, wallet analytics, Dune query results export, Dune dashboard data, execute Dune query, crypto data pipeline, Web3 analytics.

Terms and data use

Use of the Dune API is governed by Dune's General Terms and Conditions and its SQL API Service Addendum. Your API key is personal to your account: it may not be sold, sublicensed or shared, and it should never be placed in public repositories, client-side code or public dashboards, so keep it as a secret here. The addendum bars uses that act as a substitute for Dune's service or compete with Dune's business, and the general terms ask that reused public queries credit their creators. Results land in your own Apify dataset; check your Dune plan's terms before redistributing them outside your organisation. This actor is not affiliated with or endorsed by Dune.