theericstonesolscan metadata example copy
    Updated 2023-07-07
    -- forked from solscan metadata example @ https://flipsidecrypto.xyz/edit/queries/e9fab0c3-f0aa-4031-a40b-1d95410776a1

    -- here's a demo of how to use the solscan api via flipside
    -- to pull metadata info into the Studio app

    --select livequery.utils.udf_register_secret( '337429be-c5a7-441e-9a2d-7f3faf924404', 'rb7dt4rqvKC1iCXtib8BBr3FNEJU8CUK21Oa4q4Cnao=');
    with raw as (
    SELECT
    livequery.live.udf_api(
    'GET' ,
    'https://public-api.solscan.io/account/{{address}}',
    {'accept': 'application/json',
    'token': '{{apikey}}'},
    {}
    ) as response
    ),
    -- one example of organizing the metadata in particular
    -- but there are a few other pieces of info you
    -- could grab from 'raw' if you need it
    metadata as (
    select
    path,
    value
    from raw,
    lateral flatten (input => response:data:metadata:data)
    )

    select
    "'name'" as name,
    address,
    "'symbol'" as symbol,
    "'seller_fee_basis_points'" as seller_fee_basis_points,
    "'attributes'" as attributes,
    "'properties'" as properties,
    "'uri'" as uri
    from metadata