Do you know that you should utilize the Ethereum worth API from Moralis (a.ok.a. Token API) to get the value of any ERC-20 token with only a few strains of code? All you want is a single name to the Ethereum worth API’s ”getTokenPrice” endpoint whereas passing a sequence and token deal with as parameters:
const response = await Moralis.EvmApi.token.getTokenPrice({ deal with, chain, });
By familiarizing your self with the Moralis Ethereum worth API and the ”getTokenPrice” endpoint, it is possible for you to to include this performance into all future Web3 initiatives. All you should do is enroll with Moralis to leverage the complete energy of blockchain know-how immediately!

Overview
In immediately’s article, we’ll discover the perfect Ethereum worth API and learn to use this software to get token costs. To start with, we’ll kickstart this tutorial by briefly masking easy methods to get began with the Ethereum worth API from Moralis totally free. From there, we offer a sensible instance of how the API works by exhibiting you easy methods to get the value of any token in simply three steps:
- Organising Moralis
- Calling the ”getTokenPrice” endpoint
- Operating the script
As soon as you know the way to get the value of any token utilizing the Ethereum Worth API, we’ll discover this interface’s capabilities additional. Lastly, to high issues off, we’ll examine the perfect Ethereum worth API with some options provided by numerous rivals of Moralis. Be aware that the Moralis ”Ethereum worth API” and ”Token API” are used synonymously on this article.
By following alongside, you’ll at the beginning familiarize your self with the Moralis Ethereum worth API. Nonetheless, if you’re severe about entering into the Web3 area, it is best to know that Moralis gives extra blockchain growth sources.
As an illustration, an incredible instance is the testnet faucet web page, providing an inventory of the perfect crypto taps obtainable. The listing includes a Fantom testnet faucet, a Sepolia testnet faucet, the perfect Ethereum faucet, a BNB faucet, an Aptos testnet faucet, and plenty of others!
What’s extra, do you know you could entry the Ethereum worth API and another instruments from Moralis completely totally free? All you should do is enroll with Moralis, and you may instantly leverage the facility of blockchain know-how to construct smarter and quicker!

In case you are unfamiliar with APIs or have to refreshen your reminiscence, you will discover a piece earlier than the abstract answering the ”what are APIs?” query.
Get Began with the Ethereum Worth API for Free
With the enterprise-grade Ethereum worth API, you possibly can seamlessly combine real-time worth and token information into your purposes with a few strains of code. What’s extra, do you know you possibly can entry this glorious software programming interface completely totally free?
To make use of the Ethereum worth API in your growth endeavors, all you want is a Web3 API key to name the interface’s numerous endpoints. You will get your very personal key by signing up with Moralis!
Not solely does the Web3 API key present entry to the perfect token worth API but additionally to all the Web3 APIs from Moralis. As such, by registering with Moralis, you may also use the Moralis Streams API and the Moralis Authentication API, for instance!
Nonetheless, with an account at your disposal, you will discover your key by logging in to the Moralis admin panel and navigating to the ”Web3 APIs” tab:

With this key, now you can name the Ethereum worth API’s numerous endpoints. For a sensible instance of how this works, be part of us within the subsequent part as we showcase the Ethereum worth API in motion by demonstrating easy methods to get any token worth!
How you can Get Token Costs Utilizing the Ethereum Worth API
This a part of the article will exhibit easy methods to get token costs utilizing the Moralis Ethereum worth API. Additionally, the tutorial is split into the next three sections:
- Organising Moralis
- Calling the ”getTokenPrice” endpoint
- Operating the script
By finishing the steps above, you’ll learn to seamlessly get the value of any ERC-20 token very quickly! If this sounds thrilling, be part of us within the following subsections as we cowl every step intimately!
Conditions
Earlier than leaping into step one of this Ethereum worth API tutorial, you will have to take care of a few conditions:
- Set up NodeJS v.14+ or Python
- Set up npm/Yarn or pip
Relying in your preferences, you should set up NodeJS or Python and npm/Yarn or pip. The Ethereum worth API is appropriate with both of those choices. Nonetheless, for the rest of this tutorial, we’ll use NodeJS and npm to exhibit easy methods to get token costs.
Step 1: Setting Up Moralis
If in case you have not already, the very first thing you should do is enroll with Moralis. Creating an account is free and solely takes a few seconds!
With an account at hand, you could additionally set up the Moralis SDK in your NodeJS venture. To take action, open a brand new terminal and run the next command:
npm set up moralis @moralisweb3/common-evm-utils
Step 2: Calling the ”getTokenPrice” Endpoint
Now that you just’ve arrange Moralis, the following step is to create the script for calling the ”getTokenPrice” endpoint. As such, copy and enter the next code snippet into your ”index.js” file:
const Moralis = require('moralis').default; const { EvmChain } = require('@moralisweb3/common-evm-utils'); const runApp = async () => { await Moralis.begin({ apiKey: "YOUR_API_KEY", // ...and another configuration }); const deal with="0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"; const chain = EvmChain.ETHEREUM; const response = await Moralis.EvmApi.token.getTokenPrice({ deal with, chain, }); console.log(response.toJSON()); } runApp();
Within the snippet above, we name the ”getTokenPrice” endpoint whereas passing two parameters as arguments: ”deal with” and ”chain”. Which means that you should configure these two variables by including the token deal with you want to question and choosing the proper chain:

Together with configuring these two variables, you could substitute ”YOUR_API_KEY” together with your precise key. You’ll find your key by logging in to the Moralis admin panel and navigating to the ”Web3 APIs” tab:

Step 3: Operating the Script
As soon as you might be completed configuring the code, the very last thing that is still is working the script. To take action, ”cd” into the venture’s root folder and run the next command:
node index.js
Because of this, it is best to see a JSON response in your terminal trying one thing like this:
{ "nativePrice": { "worth": "13753134139373781549", "decimals": 18, "identify": "Ether", "image": "ETH" }, "usdPrice": 16115.165641767926, "exchangeAddress": "0x1f98431c8ad98523631ae4a59f267346ea31f984", "exchangeName": "Uniswap v3" }
Congratulations! You simply used the Ethereum worth API to get the value of a token with only a few strains of code!
If you wish to see the ”getTokenPrice” endpoint in motion additional, you may also try the clip beneath from the Moralis YouTube channel. On this video, one in every of our gifted software program engineers makes use of the Ethereum worth API to create a whole software for getting the value of any ERC-20 token:
Exploring the Main Worth API for Ethereum
With the enterprise-grade Ethereum worth API from Moralis, you possibly can seamlessly combine real-time worth and token information into your purposes very quickly. This consists of worth, switch, and possession information throughout all vital blockchain networks!

Listed here are three outstanding options of the main Ethereum worth API:
- Token Costs – With the Ethereum worth API, you possibly can simply question any token’s worth at any given time. Moralis accumulates costs from AMMs reminiscent of Uniswap and PancakeSwap, making them obtainable by means of simple API calls.
- Token Balances – By way of the Moralis Ethereum worth API, you possibly can seamlessly get the token stability of a consumer with a single API name.
- Token Transfers – Keep updated with probably the most related and up to date token transfers utilizing the Ethereum worth API. With this programming interface, you possibly can fetch the switch historical past of a token or pockets and observe them in real-time!
What’s extra, the Ethereum worth API is extremely versatile. For instance, this software helps all kinds of use instances, reminiscent of:
- Portfolio apps
- Transaction monitoring
- Reside worth feeds
- Possession verification
Additionally, the APIs from Moralis characteristic full cross-chain assist, that means you do not want to fret about cross-chain compatibility. As an alternative, you should utilize the identical APIs to construct purposes throughout a number of chains with Moralis. Some outstanding examples are Ethereum, BNB Chain, Polygon, Avalanche, Solana, and plenty of extra!
In the event you, as an illustration, are all in favour of Solana blockchain app growth, be sure that to additionally try the Solana Python API!
Rivals
To raised perceive why the Moralis Token API is the most suitable choice available on the market for querying the value of Ethereum tokens, allow us to take a more in-depth have a look at a few rivals. Two of Moralis’ closest and most outstanding rivals are Alchemy and QuickNode, each of which supply their very own token APIs.
As such, let’s discover these options additional to see how they differ from Moralis. To take action, enable us to start by briefly summarizing the principle capabilities and endpoints of every API within the desk beneath:

Because the desk above illustrates, all three options have loads to supply. Based mostly on the variety of endpoints and different facets, which of the three is the perfect API for crypto costs? If you need the reply to this query, be part of us within the subsequent part, the place we dive deeper into the variations between these choices!
What’s the Finest API for Crypto Costs?
By shortly glancing over the desk within the part above, you’ll instantly discover that solely Moralis gives an endpoint for fetching the value of an ERC-20 token. As such, the easy reply to the ”what’s the finest API for crypto costs?” query is the Moralis Ethereum worth API! Nonetheless, the extra attention-grabbing query is to match the three APIs total!

Initially, in relation to the variety of endpoints, Moralis outperforms each Alchemy and QuickNode. As such, Moralis gives extra performance in comparison with a few of its most outstanding rivals!
After doing a bit extra digging, we additionally got here to the conclusion that Moralis gives probably the most complete cross-chain assist. Which means that the Token API from Moralis helps extra networks than the competitors.
That mentioned, it doesn’t imply that Alchemy and QuickNode are unhealthy choices for fetching token-related information. Nonetheless, Moralis supplies all the pieces they’ve to supply and extra. As such, if you’re searching for a complete Ethereum worth API, your final alternative is Moralis!
In case you are searching for extra articles on easy methods to combine token information, you will discover extra guides right here on the weblog. As an illustration, learn to get token metadata, get the token stability of an deal with, or get all tokens owned by a pockets!
What are APIs?
In immediately’s interconnected world, cross-system communication is important to internet and software growth. Purposes and platforms don’t work optimally in isolation, so builders want environment friendly methods to allow software program techniques to speak. That is the place software programming interfaces (APIs) enter the equation!
When shopping the net or utilizing an software, your machine connects to the web to ship directions to a server or database. From there, the receiving finish takes within the information, interprets it, finds the suitable response(s), and returns it to your machine. Subsequent, your system handles the response and presents the info in a readable format.

An API usually facilitates this course of, enabling two separate techniques to speak. These interfaces accomplish this by translating directions for mutual understanding and delivering features reliably on queries. Furthermore, this additionally permits appropriate coding in safe and secure environments, contributing to a extra accessible developer expertise!
That briefly covers the ins and outs of APIs. If you wish to know extra about APIs, try our article exploring Web3 APIs in additional element!
Abstract – The #1 Ethereum Worth API
On this article, you bought to discover the intricacies of the Ethereum worth API from Moralis and why that is the most suitable choice available on the market. In doing so, we supplied a fast instance of how the API works in follow by exhibiting you easy methods to get the value of any ERC-20 token. All you actually wanted was a single API name to the ”getTokenPrice” endpoint:
const response = await Moralis.EvmApi.token.getTokenPrice({ deal with, chain, });
In the event you discovered this tutorial useful, try extra blockchain growth content material right here on the Web3 weblog. For instance, examine Avalanche’s Fuji testnet, easy methods to use a Goerli faucet, or discover the perfect Notify API options!
What’s extra, if you’re all in favour of starting your Web3 journey, be sure that to take a look at Moralis Academy. The academy gives a collection of blockchain growth programs for skilled and new builders. As such, that is the perfect place to kickstart your Web3 growth journey. For instance, study in regards to the fundamentals of the business by enrolling within the ”Ethereum 101” course.
Additionally, keep in mind to enroll with Moralis if you wish to entry the perfect Ethereum worth API, together with different enterprise blockchain options. In doing so, you possibly can leverage the complete potential of blockchain know-how to construct purposes quicker and smarter!