Python
Installdune-client:
DUNE_API_KEY from the environment when no key is passed explicitly.
run_query and run_sql return ResultsResponse, not a row array. Python’s high-level run_query fetches all result pages. The older execute(QueryBase(...)) method only submits a query and returns an execution ID and state.
For a parameterized saved query, put the parameters on QueryBase:
run_sql does not apply query parameters. Use a saved query for parameterized SQL.
DataFrames and result filtering
batch_size controls the number of rows per request, not the total number of rows returned. get_latest_result(query_id, max_age_hours=8) may run the query again when its cached result is older than eight hours, consuming execution credits.
Query management and uploads
dune.get_execution_status(execution_id) and dune.cancel_execution(execution_id). The argument is called job_id if you pass it by keyword.
Python SDK guide
TypeScript
Install@duneanalytics/client-sdk:
runQuery submits a saved query, polls until it finishes, and returns a ResultsResponse. Its result?.rows contains one page, not necessarily the full dataset. Check next_uri or next_offset and fetch additional pages with dune.exec.getExecutionResults(response.execution_id, { limit, offset }); see pagination.
For raw SQL, dune.exec.executeSql({ sql: "SELECT 1 AS value" }) submits an execution. Poll with dune.exec.getExecutionStatus(execution_id), then fetch a page with dune.exec.getExecutionResults(execution_id). Alternatively, dune.runSql({ query_sql: "SELECT 1 AS value" }) creates a saved query, runs it, and archives it by default; it requires a Plus subscription.
dune.getLatestResult({ queryId: 3493826 }) reads the latest result, following pages when it is still fresh. It can rerun an expired result, in which case the returned rows may again be only one page. Do not assume any TypeScript method retries failed requests automatically.
Query management and uploads are available through dune.query and dune.uploads, respectively.
TypeScript SDK guide
Go
Install the Go client:Rust
Install the publishedduners crate with cargo add duners. Add serde with its derive feature and tokio with macros and rt-multi-thread to run the example.
run_query::<Row>(query_id, None, None) runs a saved query. Both methods wait for completion and fetch all result pages.
Rust SDK guide