theericstonehelius livequery demo
    Updated 2024-11-27
    with raw as (
    SELECT livequery.live.udf_api(
    'GET',
    'https://api.helius.xyz/v0/addresses/{{soladdress}}/balances?api-key={apikey}',
    {'accept': 'application/json'},
    {},
    'helius'
    ) as response
    ),
    tokens as (
    select
    value:mint::string as token,
    value:amount / pow(10,value:decimals) as amount
    from raw,
    lateral flatten (input => response:data:tokens)
    ),
    nativesol as (
    select 'sol' as token,
    response:data:nativeBalance / pow(10,9) as amount
    from raw
    )
    select * from tokens
    UNION
    select * from nativesol
    order by amount desc;
    QueryRunArchived: QueryRun has been archived