Token Price FAQ
Overview
How does the Moralis Token Price API work?
Our Token Price API retrieves the last traded price of a token from a specific pool and exchange. It differs from services like Coingecko or Coinmarketcap, which calculate average weighted prices across multiple exchanges.
What types of pools are considered for token prices?
We consider two types of pools:
- Native token pairs
- Stablecoin pairs
If a token does not have either pairing, no price is returned, and an error stating "no liquidity pool found" is provided.
Are token prices available on testnets?
No, token prices are only available on mainnet because they rely on data from decentralized exchanges (DEXes). Since most testnets do not have active DEX liquidity, token price features will not work on testnets.
What features are affected by this?
Since token prices are only available on mainnet, any features that depend on prices—such as portfolio_percentage
in getWalletTokenBalancePrices
—are also only supported on mainnet.
Price Calculation
What is the definition of price in the API?
The price is based on the last traded price extracted from the swap log event. This value is converted to USD for the token price.
How does the API handle multiple swaps within the same block?
If multiple swaps occur within a block, the final price as of that block is returned. We do not track granular price fluctuations within a block.
Pool Selection
How are pools selected for real-time prices?
For real-time prices:
- Exchanges with low liquidity are skipped.
- The pool with the most swaps in the last 24 hours is selected.
How are pools selected for historical prices?
For historical prices:
- The top 2 pools based on lifetime usage are selected.
- The last record from each pool is compared.
- The pool with higher liquidity is chosen.
Liquidity and Stability
What are the liquidity thresholds for tokens?
The default liquidity thresholds are:
- Ethereum: $500
- Other chains: $150
- Solana: No liquidity threshold
What happens when a token pair's liquidity is below the threshold?
- GetMultipleTokenPrices: Low liquidity tokens are omitted.
- GetTokenPrice: A
404
error is returned with a message about insufficient liquidity. - GetWalletTokenBalancePrice: Token price is returned as
null
. - GetWalletNetWorth: Token price is excluded from the net worth calculation.
Can liquidity thresholds be customized?
Yes, using the min_pair_side_liquidity_usd
query parameter, you can set a custom threshold. For example:
min_pair_side_liquidity_usd=5000
ensures only pairs with at least $5000 in liquidity are considered.
Inactivity Handling
How does the API handle inactive tokens?
Tokens with no trading activity for extended periods can be excluded using the max_token_inactivity
query parameter. For example:
max_token_inactivity=14
excludes tokens without trading activity for 14 days.
What happens when a token is considered inactive?
- GetMultipleTokenPrices: Inactive tokens are omitted.
- GetTokenPrice: A
400
error is returned with a message about no trading activity. - GetWalletTokenBalancePrice: Token price is returned as
null
. - GetWalletNetWorth: Token price is excluded from net worth calculation.
Errors and Edge Cases
What errors can I expect when fetching token prices?
- No liquidity pool found: Returned when no native or stablecoin pairs exist.
- Insufficient liquidity: Returned if the pair's liquidity is below the threshold.
- Inactive token: Returned if the token has not been traded for the specified inactivity period.
- Testnet request: Token prices and price-related features do not work on testnets.
Can I retrieve token prices for custom conditions?
Yes, you can customize liquidity thresholds (min_pair_side_liquidity_usd
) and inactivity periods (max_token_inactivity
) to fit your needs.