Skip to main content

Introduction

In this tutorial, you’ll learn how to rank ERC20 tokens by market cap using the Moralis API. You can also sort by trading volume and liquidity. This is useful for building token discovery platforms, market dashboards, or trading screeners. We’ll use the following Moralis API endpoint:
  • Token Search - Search and rank tokens by market cap, volume, or liquidity
Token Search requires a query, so it ranks the tokens matching your search rather than the entire token universe. There is no endpoint that returns a global top N by market cap. If that’s what you need, reach out to the team (via chat widget).

Prerequisites

  • Node.js v18+ installed
  • A Moralis API key (get one)

Step 1: Set Up Your Project

Create a new directory for your project and initialize it:

Step 2: Create the Script

Create a file called index.js and add the following code:
Replace YOUR_API_KEY with your actual Moralis API key.

Step 3: Run the Script

Execute the script to get tokens ranked by market cap:

Query Parameters

Example Response

Understanding the Response

Next Steps