Introduction
In this tutorial, you’ll learn how to get the current USD price of any ERC20 token using the Moralis API. This is essential for building price trackers, trading interfaces, or portfolio applications that need real-time token pricing. We’ll use the following Moralis API endpoint:- Get Token Price - Fetch the current price of any ERC20 token
Prerequisites
- Node.js v18+ installed
- A Moralis API key (get one free)
Step 1: Set Up Your Project
Create a new directory for your project and initialize it:Step 2: Create the Script
Create a file calledindex.js and add the following code:
YOUR_API_KEY with your actual Moralis API key.
Step 3: Run the Script
Execute the script to fetch the token price:Example Response
Understanding the Response
| Field | Description |
|---|---|
tokenName | The full name of the token |
tokenSymbol | The token’s ticker symbol |
tokenLogo | URL to the token’s logo image |
tokenDecimals | Number of decimal places the token uses |
nativePrice | Price in the chain’s native token (ETH) |
usdPrice | Current price in USD |
24hrPercentChange | Price change percentage over 24 hours |
exchangeAddress | DEX address where the price was sourced |
exchangeName | Name of the DEX (e.g., Uniswap v3) |
Next Steps
- Get Historical Prices (OHLC) - Fetch OHLC candlestick data
- Build Price Charts - Create interactive price charts
- API Reference - Full API documentation

