[SOLVED] Get token price from Uniswap V3

I’m using the Token API get prices ([https://docs.moralis.io/reference/gettokenprice]). Getting prices from Quickswap works well, however when I try to get prices from Uniswap it fails with a 404/Invalid Exchange error.

Is it possible to get prices from Uniswap V3? If so, what is the correct name or address to use for the “exchange” parameter?

So far I have tried:
0x1F98431c8aD98523631AE4a59f267346ea31F984
0xe592427a0aece92de3edee1f18e0157c05861564
Uniswap
UniswapV3Factory

My code looks like:

const priceResponse = await Moralis.EvmApi.token.getTokenPrice({
          address: tokens[i].token_address,
          chain: chain,
          exchange: '0xE592427A0AEce92De3Edee1F18E0157C05861564'
        });

it should be uniswapv3 the name

Thanks, unfortunately I’m still getting the “Invalid Exchange” error both from my code and the docs page. Also tried various capitalizations with no luck…

this code works in python

from moralis import evm_api

api_key = "YOUR_API_KEY"

params = {
    "exchange": "uniswapv3",
    # token 0 address, e.g. WETH token address
    "token0_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", 
    # token 1 address, e.g. LINK token address
    "token1_address": "0x514910771AF9Ca656af840dff83E8264EcF986CA", 
    "chain": "eth"
}

result = evm_api.defi.get_pair_address(
    api_key=api_key,
    params=params,
)

print(result)

this also works in docs page:

curl --request GET \
     --url 'https://deep-index.moralis.io/api/v2/erc20/0xdac17f958d2ee523a2206206994597c13d831ec7/price?chain=eth&exchange=UniswapV3' \

maybe try with UniswapV3 ? uniswapv3 also works for me

1 Like

It works with chain set to “eth”. I had it set to polygon, because technically the token I’m querying is on polygon, but it finds it using chain “eth” and exchange “UniswapV3”. Thanks for your help!