[SOLVED] I can't get token USD using Token API

reference: https://docs.moralis.io/web3-data-api/reference/get-token-price
my code is

import Moralis from ‘moralis’;
import { EvmChain } from ‘@moralisweb3/evm-utils’;

try {
const chain = EvmChain.ETHEREUM;

const address = ‘0x1234567890123456789012345678901234567890’;

await Moralis.start({
apiKey: ‘4324234’,
// …and any other configuration
});

const response = await Moralis.EvmApi.token.getTokenPrice({
address,
chain,
});

console.log(response?.result);
} catch (e) {
console.error(e);
}

response is zero.

but https://etherscan.io/dex/uniswapv3/0x7335118ece5464167ec940c4dba3291d1484e00f
is still alive
same exchange uniswap-v3

it looks like the liquidity is small for that token

https://etherscan.io/dex/uniswapv3/0x7335118ece5464167ec940c4dba3291d1484e00f
=>
Total Liquidity: $62.18

We don’t return the price for tokens that have a low liquidity value

1 Like

I see.
Just I want to get Price like CoinMarketCap.
but it might be impossible…

Hey @sloth,

for smaller coins, recommend that you check either CoinMarketCap or CoinGecko API for that. Our price data are fetched from DEX instead of CEX, but that means it also heavily rely on liquidity data that exist within the DEX.

Let me know if you have any other questions, otherwise I’ll be closing this one ASAP :grinning_face_with_smiling_eyes:

1 Like

This topic was automatically closed after 32 hours. New replies are no longer allowed.