Calculate correct price

Hey there,
I am using https://deep-index.moralis.io/api/v2/erc20… to get the erc20 token eth and usd price.
But it returns something weird and I wanted to ask what I would need to do to get the 1:1 usd price of that requested token with the response this endpoint give me. I want the same price etherscan shows me.

exchangeAddress: "0x1f98431c8ad98523631ae4a59f267346ea31f984"
​
exchangeName: "Uniswap v3"
​
nativePrice: Object { value: "596082550119330", decimals: 18, name: "Ether", … }
​
usdPrice: 1.0004000600027727

This is the response of my 12.96$ usdt token. How can i get that exact 12.96$ in usd currency and i want it to work also for any token that comes

you can try with exchange: uniswapv2

thank you for reply. Can you please explain a bit more. Why do i have to interact with uniswap after that request ?

I mean that when you do the original request you can set the exchange parameter to uniswapv2, that response is specific to uniswap v3 and on uniswapv2 you may get the expected price

what do you mean by this?

but what is it returning ? i thought moralis would return 12$ as this is the price of my usdt token. But instead i get 0.00001 $ or similar. What caluclation do i need to make to get to the 12$

what was the code that you used to get that price?
you want to get the price of USDT?

this is what moralis returns. I dont know what im suppsoed to do with those values

what code did you run to get those results?

simple api request with toke congract address and chain set to eth. Thats it

you wan to get a wallet balance for that token or you want to get the price for a token or something else?

with what parameters did you run that code?

wallet balance. I want to know how much this certain wallet address has in erc20. Usdt for 12$ and then matic for 30$ etc…

you have to use first this api function to find out what is the balance for all the tokens that an wallet address has

after that you can multiply that balance with a price, you will also have to convert the balance from wei as you have the balance in wei and the number of decimals

for example if you have:

  {
    "token_address": "0x56ed3192f74a4dca3c733aebc63ce18e5f3dd33a",
    "name": "DogeSino",
    "symbol": "DogeSino",
    "logo": null,
    "thumbnail": null,
    "decimals": 18,
    "balance": "101165372024016207849838293114344"
  },

you have to get the balance with 18 decimals that could be 101165372024016 and then you can multiply it with the price of that token

then i would have the price in eth, but i want it in usd ? Do i need to include a extra api ?

here you have the price in USD for a token, probably in this particular case it was USDT token

but when I open metamask. I have 12$

you have to get the balance first with this function and then to multiply it with that price un USD