Skip to content

Import Data from Dune

Importing a Query

  1. Identify the specific Dune query you want to import.
  2. From the URL, select the first number (the query id).

    Dune Query Screenshot

  3. On Rose, in a code block < > use the push function to import the query results; where the query_id is the Dune query id from the URL and the rosecode is a descriptive name you assign to that data. There are three ways to push a query: as a map, as a timeseries with the date column stated, as a timeseries without a date column stated.

As a Map

The first and simplest way is as a map. This method is best for data that is not a timeseries, but it is possible to Convert a Map to a Timeseries on Rose after pushing from Dune.

dune:push(rosecode, query_id)

dune:push(test.dune.push.rww, 3469)

As a Timeseries

To import Dune data directly to Rose as a timeseries specify the name of the value column (required) and date column (optional) when pushing. For best results, include the name of the date column, however if not specified, Rose will infer the date column from the query result.

dune:push(rosecode, query_id, value_column, [date_column])

dune:push(test.dune.push.ts.rww, 3469, usd, month)

Converting a Map to a Timeseries

After importing Dune data as a map, we can convert it to a timeseries on Rose using the :ts(date_column, value_column) function.

test.dune.push.rww:ts(month, usd)

Next, we can save this timeseries as its own object using new_rosecode = rosecode:ts(date_col, value_col). Remember that you can always ""Show Tree"" to review the logic behind how a rosecode was built." test.dune.push.rww.ts

Notes

If you do not have an active Dune subscription linked to your Rose account, you will only be able to import the results from the last time the query was run on Dune.