kays0xDefillama API Demo copy
    -- forked from Defillama API Demo @ https://flipsidecrypto.xyz/edit/queries/e87b0657-1a8d-4607-a5a6-8ce22ca5afb6

    /* Query defillama API to list all protocols along
    with summaries of their fees by chain (Ethereum only in this template) */
    WITH
    json AS (
    SELECT
    livequery.live.udf_api (
    'https://api.llama.fi/overview/fees/ethereum?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true&dataType=dailyFees'
    ) AS response
    )
    SELECT
    VALUE:name::STRING as protocol,
    REPLACE(REPLACE(VALUE:chains::STRING, '["', ''), '"]', '') as chain,
    VALUE:total24h::INT as "24hfee",
    VALUE:total30d::INT as "30dfee",
    VALUE:methodology:Fees::STRING as description
    FROM
    json,
    LATERAL FLATTEN(input => response:data:protocols)
    WHERE
    "24hfee" > 0
    ORDER BY
    3 DESC,
    4 DESC


    Run a query to Download Data