cybergenlabDune Extract Tuto
    Updated 2024-12-30
    --LiveQuery API call
    with dune_data AS (
    SELECT livequery.live.udf_api(
    'https://api.dune.com/api/v1/query/4500341/results?api_key={key1}',
    'dune_key'
    ) AS response
    )

    , flatten_dune_data AS (
    SELECT * FROM dune_data, table(flatten(response, ''))
    )

    --Parse the initial response to only save data from the Dune Table
    , data as (
    SELECT
    value:result:rows as table_data
    FROM flatten_dune_data
    )

    --Final table
    SELECT
    vm.value:day::date as date,
    vm.value:symbol::string as symbol,
    vm.value:price::numeric as price
    from
    data
    , LATERAL FLATTEN(table_data) vm
    order by 1




    /*
    SELECT
    vm.value:issuer::string as issuer,
    vm.value:address::string as address,
    QueryRunArchived: QueryRun has been archived