v1

latestOpenAPI 3.0.12026-07-22367385.5 KB

Get Latest Query Result

Given a query ID, returns the latest executed result of a query on Dune in JSON format

get/v1/query/{query_id}/results

Path parameters

query_idstring required

Query ID

Query parameters

api_keystring

Alternative to using the X-Dune-Api-Key header

allow_partial_resultsboolean

This enables returning a query result that was too large and only a partial result is available. By default, allow_partial_results is set to false and a failed state is returned.

columnsstring

Specifies a comma-separated list of column names to return. If omitted, all columns are included. Tip: use this to limit the result to specific columns, reducing datapoints cost of the call.

filtersstring

Expression to filter out rows from the results to return. This expression is similar to a SQL WHERE clause. More details about it in the Filtering section of the doc. This parameter is incompatible with sample_count.

ignore_max_credits_per_requestboolean

To bypass the default max credits per request limit, set ignore_max_credits_per_request=true

limitinteger

Limit number of rows to return. This together with 'offset' allows easy pagination through results in an incremental and efficient way. This parameter is incompatible with sampling (sample_count).

offsetinteger

Offset row number to start (inclusive, first row means offset=0) returning results from. This together with 'limit' allows easy pagination through results in an incremental and efficient way. This parameter is incompatible with sampling (sample_count).

queryIDinteger required
sample_countinteger

Number of rows to return from the result by sampling the data. This is useful when you want to get a uniform sample instead of the entire result. If the result has less than the sample count, the entire result is returned. Note that this will return a randomized sample, so not every call will return the same result. This parameter is incompatible with offset, limit, and filters parameters.

sort_bystring

Expression to define the order in which the results should be returned. This expression is similar to a SQL ORDER BY clause. More details about it in the Sorting section of the doc.

Headers

X-Dune-Api-Keystring required

API Key for the service

Response

OK

cancelled_atstring

Timestamp of when the query execution was cancelled, if applicable.

execution_ended_atstring

Timestamp of when the query execution ended.

execution_idstring

Unique identifier for the execution of the query.

execution_started_atstring

Timestamp of when the query execution started.

expires_atstring

Timestamp of when the query result expires.

is_execution_finishedboolean

Whether the state of the query execution is terminal. This can be used for polling purposes.

next_offsetinteger

Offset that can be used to retrieve the next page of results.

next_uristring

URI that can be used to fetch the next page of results.

query_idinteger

Unique identifier of the query.

statestring

The state of the query execution.

submitted_atstring

Timestamp of when the query was submitted.

Example response

{
  "cancelled_at": "2024-12-20T11:04:18.724658237Z",
  "error": {
    "message": "Error: Line 1:1: mismatched input 'selecdt'",
    "metadata": {
      "column": 73,
      "line": 10
    },
    "type": "syntax_error"
  },
  "execution_ended_at": "2024-12-20T11:04:18.724658237Z",
  "execution_id": "01HKZJ2683PHF9Q9PHHQ8FW4Q1",
  "execution_started_at": "2024-12-20T11:04:18.724658237Z",
  "expires_at": "2024-12-20T11:04:18.724658237Z",
  "is_execution_finished": true,
  "next_offset": 100,
  "next_uri": "https://api.dune.com/api/v1/execution/01HKZJ2683PHF9Q9PHHQ8FW4Q1/results?offset=100&limit=100",
  "query_id": 1234,
  "result": {
    "metadata": {
      "column_names": [
        "Rank",
        "Project",
        "Volume"
      ],
      "column_types": [
        "double",
        "varchar",
        "bigint"
      ],
      "datapoint_count": 1000,
      "execution_time_millis": 1000,
      "pending_time_millis": 1000,
      "result_set_bytes": 1000,
      "row_count": 10,
      "total_result_set_bytes": 10000,
      "total_row_count": 1000
    }
  },
  "state": "QUERY_STATE_COMPLETED",
  "submitted_at": "2024-12-20T11:04:18.724658237Z"
}