Embed Crypto Search – How to Build a Crypto Search Bar


Token search on wallets, DEXs, and other Web3 platforms is often broken, flooded with scams, and outright missing popular assets like Pepe. Fortunately, Moralis fixes that. With the Token Search API, you can easily find any token by name, symbol, address, or pair address across all major chains using just one API call. Build and embed a world-class crypto search bar into your project in minutes!

Short on time? Here’s a script showing the Token Search API in action: 

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch('https://deep-index.moralis.io/api/v2.2/tokens/search?query=pepe&chains=eth', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

Running the code above provides a list of tokens matching the query parameters. Here’s a sample response:

{
  //...
  result: (
    {
      "tokenAddress": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
      "chainId": "0x1",
      "name": "Pepe",
      "symbol": "PEPE",
      "blockNumber": null,
      "blockTimestamp": 1681483895,
      "usdPrice": 0.000008732159701029,
      "marketCap": 3673532264.62589,
      "experiencedNetBuyers": {
        "oneDay": 6,
        "oneWeek": 12
      },
      "netVolumeUsd": {
        "oneDay": -308278.47758801375
      },
      "liquidityChangeUSD": {
        "oneDay": -109445.76999999955
      },
      "usdPricePercentChange": {
        "oneDay": -3.2959040909090422
      },
      "volumeUsd": {
        "oneDay": 1570513.1603542287
      },
      "securityScore": 92,
      "logo": "https://adds-token-info-29a861f.s3.eu-central-1.amazonaws.com/marketing/evm/0x6982508145454ce325ddbe47a25d4ec3d2311933_icon.png",
      "isVerifiedContract": true,
      "fullyDilutedValuation": 3673531388.384607,
      "totalHolders": 427466
    },
    //...
  )
}

That’s it; with one single API call, you can use the Token Search API to build and embed a crypto search bar into your platform without breaking a sweat! 

To learn more about this, join us in today’s guide as we dive deeper into the Token Search API. Or, if you immediately want to use this premier tool yourself, get your API key using the button below: 

 

Overview

Building a crypto search bar is not an easy task, as it requires live blockchain indexing, multi-chain support, smart ranking systems, and much more. Doing this all from scratch takes an abundance of time and effort that can be spent on other critical parts of building a crypto project. Fortunately, you can now streamline this process with Moralis’ Token Search API!

The Token Search API handles everything from real-time indexing to cross-chain support, meaning you don’t have to worry about any underlying complexities. In turn, you can search for any token by symbol, name, address, or pair address, allowing you to build and embed a crypto search bar into your project with just one API call.

If you’d like to learn more about how this works, join us in today’s tutorial as we lay it all out. Let’s dive straight in!

Crypto Search Bar Example

A crypto search bar is a tool allowing users to find tokens by name, symbol, address, or pair address. It’s a standard feature across most crypto platforms – including wallets, decentralized exchanges (DEXs), on-chain analytics websites, etc. – which is why building a search bar is an essential skill for most Web3 developers. Here’s an example of what it can look like:

The example above comes from Moralis.com – a leading DEX terminal and on-chain analytics platform. It prioritizes verified results, supports partial matches, and features additional data such as each token’s real-time price. That way, users can find relevant tokens without skipping a beat. 

If you want to build and embed a token search bar like the one above into your own platform, join us below as we introduce you to the industry’s #1 crypto data provider: Moralis for Developers!

Introducing Moralis for Developers – Get the Data to Build a Crypto Search Bar

Moralis is the industry’s most prominent crypto data provider, supplying world-class APIs and RPC nodes that help you build projects faster and more efficiently. Search for any crypto, fetch a wallet’s fully decoded history, get token balances with prices, and much more with only a single API request. Access the tools, data, and resources you need to build powerful crypto features – all in one place!

Moralis logo.

Here’s why Moralis is the #1 crypto data provider: 

  • More Data. Fewer Requests: Moralis’ APIs are outcome-oriented, minimizing the requests you need to build advanced crypto features. Build a crypto search bar, comprehensive portfolio views, transaction timelines, and much more with minimal development effort.



  • Multi-Chain Support: Moralis supports all major blockchain networks, including Solana, Ethereum, Polygon, Base, Optimism, BNB Smart Chain (BSC), and more. Build fully cross-chain compatible projects with one unified toolkit. 



  • SOC 2 Type 2: With a SOC 2 Type 2 certificate, Moralis ensures enterprise-grade reliability and security across all tools and features. 

With an overview of Moralis, let’s explore our Token Search API, which allows you to build and embed a crypto search bar with just one API request!

Token Search API: Easiest Way to Build & Embed a Crypto Search Bar

The Token Search API provides live, verified crypto search across all major EVM chains and the Solana network. Find any cryptocurrency token by name, symbol, address, or pair address – with real-time indexing, smart ranking, and in-depth metadata. Build and embed a crypto search bar into your wallet, DEX, or other platform – with one API call!

Token Search API.

Here are some key features and benefits of the Token Search API: 

  • Multi-Chain Support: Find tokens across the entire Web3 ecosystem with support for chains like Solana, Ethereum, BSC, Optimism, Base, Polygon, etc. 



  • Sorted Results: Sort by any network to get quick, chain-specific results.



  • Smart Token Search: Search for tokens by symbol, name, address, or pair address with support for partial matches and verified results ranked first. 



  • Detailed Payload Data: Receive detailed metadata for all search results, including real-time prices, market cap, holders, liquidity change, and much more. 

With an overview of this industry-leading tool, let’s take a closer look at how you can use the Token Search API to build and embed a crypto search bar into your project!

Complete Tutorial: How to Build & Embed a Crypto Search Bar in 3 Steps

With the Token Search API, you can build a crypto search bar in three simple steps: 

  1. Get Your Moralis API Key



  2. Write a Script



  3. Run the Code

But before you get going, you need to handle a few prerequisites!

Prerequisites

To join us in today’s tutorial, make sure you have these installed: 

Step 1: Get Your Moralis API Key

To kick things off, start by creating a Moralis account by clicking the button at the top right: 

Arrow pointing at "Start for Free" button.

Next, upgrade to either a custom Enterprise or Business plan, as the Token Search API is a premium tool. Once you’ve upgraded, you’ll find your API key under the ”Home” tab on the Moralis admin panel: 

Arrow pointing at copy button for API key.

Copy and save your key for now, as you’ll need it in the next step!

Step 2: Write a Script

Set up a new project using the following terminal command: 

npm init

Install the required dependencies: 

npm install node-fetch --save
npm install moralis @moralisweb3/common-evm-utils

Open your ”package.json” file and add ”type”: ”module”

"type": "module" highlighted in code editor.

Create a new file called ”index.js” and add the following script: 

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch('https://deep-index.moralis.io/api/v2.2/tokens/search?query=pepe&chains=eth', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

From here, you need to make a few configurations to the code. Start by replacing YOUR_API_KEY with the key you copied previously. Next, you might also want to change the query parameters. For example, add additional chains or include the isVerifiedContract boolean to only receive verified tokens in the results: 

Code configurations for script.

Step 3: Run the Code

To execute the code, open a new terminal and run the following command in your project’s root folder: 

node index.js

In return, you’ll get an array of tokens with real-time prices, market caps, security scores, price changes over time, and much more. Here’s a sample response: 

{
  //...
  result: (
    {
      "tokenAddress": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
      "chainId": "0x1",
      "name": "Pepe",
      "symbol": "PEPE",
      "blockNumber": null,
      "blockTimestamp": 1681483895,
      "usdPrice": 0.000008732159701029,
      "marketCap": 3673532264.62589,
      "experiencedNetBuyers": {
        "oneDay": 6,
        "oneWeek": 12
      },
      "netVolumeUsd": {
        "oneDay": -308278.47758801375
      },
      "liquidityChangeUSD": {
        "oneDay": -109445.76999999955
      },
      "usdPricePercentChange": {
        "oneDay": -3.2959040909090422
      },
      "volumeUsd": {
        "oneDay": 1570513.1603542287
      },
      "securityScore": 92,
      "logo": "https://adds-token-info-29a861f.s3.eu-central-1.amazonaws.com/marketing/evm/0x6982508145454ce325ddbe47a25d4ec3d2311933_icon.png",
      "isVerifiedContract": true,
      "fullyDilutedValuation": 3673531388.384607,
      "totalHolders": 427466
    },
    //...
  )
}

That’s it – searching for a token with Moralis is that easy. From here, you can now embed this code into your project and make it dynamic based on user input to build fast, accurate crypto search functionality!

If you’d like to learn more about this and try the endpoint yourself, please check out the token search documentation page! 

Beyond Crypto Search – Embed Price Chart & Token Page Widgets with Moralis.com

Top-tier crypto search functionality is only one of many features you can enrich your platform with when using Moralis. Other examples include candlestick charts and token pages, which you can seamlessly embed using our Crypto Widgets! 

Moralis currently provides two types of widgets: 

  • Price Chart Widget: Supercharge your platform with interactive candlestick charts that give users insight into real-time and historical prices. Additionally, this widget also gives you the option to include a holders chart, showing the long-term development of a token’s holder count. Here’s what it looks like for Wrapped Bitcoin (WBTC):
Price chart widget example.

  • Token Page Widget: Integrate a full Moralis token page into your project, featuring insight into real-time prices, liquidity metrics, market cap, holders, live events, transactions, etc. Give your users the data they need to thoroughly analyze a crypto token. Here’s what it can look like: 
Token page widget example.

Check out Moralis’ Crypto Widgets page to learn more about this!

Exploring Other Moralis Tools & Features

In addition to the Token Search API, Moralis offers various other industry-leading tools. Here are three examples we’ll dive a bit deeper into in this article: 

  1. Wallet API



  2. Token API



  3. Price API

Check out all Moralis tools on the Web3 API page! 

Wallet API: Get a Wallet’s Net Worth, Token Balances, & Decoded History

With Moralis’ cross-chain compatible Wallet API, you can easily get a wallet’s net worth, profitability, decoded transaction history, token balances with prices, and much more using only a single API call. Use this premier tool to supercharge your platform with detailed portfolio views, in-depth transaction timelines, and much more without breaking a sweat. 

Wallet API.

Here are a few key endpoints of the Wallet API: 

  • /wallets/:address/net-worth: Get the net worth of a wallet, along with breakdowns for each chain.



  • /wallets/:address/profitability/summary: Query a summary of a wallet’s profitability.



  • /wallets/:address/defi/positions: Fetch the DeFi positions of a wallet. 



  • /wallets/:address/tokens: Get token balances with prices of any wallet.



  • /wallets/:address/history: Fetch a wallet’s decoded transaction history.

To highlight the accessibility of this world-class tool, we’ll now show you how easy it is to get a wallet’s net worth when using Moralis. Here’s a sample script: 

import fetch from 'node-fetch';

const options = {
  method: 'GET',
  headers: {
    accept: 'application/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
};

fetch('https://deep-index.moralis.io/api/v2.2/wallets/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/net-worth?chains%5B0%5D=eth&chains%5B1%5D=polygon&exclude_spam=true&exclude_unverified_contracts=true', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Calling the endpoint above returns the wallet’s total net worth, along with breakdowns for all specified chains. Here’s what it can look like:

{
  "total_networth_usd": "4286806.08",
  "chains": (
    {
      "chain": "eth",
      "native_balance": "1085515469813080189177",
      "native_balance_formatted": "1085.515469813080189177",
      "native_balance_usd": "3550067.16",
      "token_balance_usd": "735008.04",
      "networth_usd": "4285075.20"
    },
    {
      "chain": "polygon",
      "native_balance": "426857449018746625825",
      "native_balance_formatted": "426.857449018746625825",
      "native_balance_usd": "445.31",
      "token_balance_usd": "1285.57",
      "networth_usd": "1730.88"
    }
  )
}

Token API: Fetch Token Holders, Swaps, & Snipers

The Token API lets you fetch everything from holder insights to detailed swap data for tokens across all major EVM chains and the Solana network. Use this powerful tool to enrich your platform with real-time transaction tables, in-depth token analytics, and other similar features with minimal development effort. 

Let’s look at a quick overview of the Token API’s endpoints: 

  • /erc20/:token_address/owners: Query an array of a token’s top holders.



  • /erc20/:address/holders: Get holder stats for any token.



  • /erc20/:address/swaps: Fetch all swap-related transactions of a token.



  • /tokens/:address/analytics: Access analytics for a token, including volume, buyers, liquidity, etc.



  • /pairs/:address/snipers: Query the snipers of any token pair.

To demo the Token API, we’ll now show you how to get a token’s holder stats. Here’s what it can look like: 

import fetch from 'node-fetch';

const options = {
  method: 'GET',
  headers: {
    accept: 'application/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
};

fetch('https://deep-index.moralis.io/api/v2.2/erc20/0x6982508145454ce325ddbe47a25d4ec3d2311933/holders?chain=eth', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

The endpoint above gives you in-depth insight into token holders, including acquisition data, supply distribution, short-term trends, etc. Here’s a sample response:

{
  totalHolders: 429679,
  holdersByAcquisition: { swap: 123428, transfer: 290323, airdrop: 15928 },
  holderChange: {
    '5min': { change: -5, changePercent: -0.0012 },
    '1h': { change: 22, changePercent: 0.0051 },
    '6h': { change: 141, changePercent: 0.033 },
    '24h': { change: 378, changePercent: 0.088 },
    '3d': { change: 1233, changePercent: 0.29 },
    '7d': { change: 2722, changePercent: 0.63 },
    '30d': { change: 9278, changePercent: 2.2 }
  },
  holderSupply: {
    top10: { supply: '163769693937014.17', supplyPercent: 39 },
    top25: { supply: '223722370620383.91', supplyPercent: 53 },
    top50: { supply: '270654016655895.11', supplyPercent: 64 },
    top100: { supply: '307552270787111.22', supplyPercent: 73 },
    top250: { supply: '344543201407311.47', supplyPercent: 82 },
    top500: { supply: '363125388956983.28', supplyPercent: 86 }
  },
  holderDistribution: {
    whales: 110,
    sharks: 70,
    dolphins: 620,
    fish: 2145,
    octopus: 6132,
    crabs: 22060,
    shrimps: 398542
  }
}

Price API: Query Real-Time Prices, OHLCV Data, & NFT Floor Prices

The Price API is a leading tool for fetching and integrating price-related data into Web3 projects. With this premier interface, you can get real-time and historical prices for both fungible and non-fungible tokens (NFTs). Use the Price API to easily enrich your project with accurate prices, interactive candlestick charts, and much more. 

Here are a few examples of prominent endpoints:

  • /erc20/:address/price: Fetch the price of a token denominated in both the chain’s native currency and USD.



  • /pairs/:address/ohlcv: Query OHLCV candlestick data for any pair address.



  • /nft/:address/:token_id/floor-price: Get the floor price of a given NFT.



  • /nft/:address/:token_id/price: Fetch sale prices for an NFT within a specified time period.

To highlight the accessibility of the Price API, we’ll now show you how to get OHLCV data for any pair address. Here’s a sample script: 

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch('https://deep-index.moralis.io/api/v2.2/pairs/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640/ohlcv?chain=eth&timeframe=1h&currency=usd&fromDate=2024-12-25&toDate=2025-01-01', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

Running the code above will provide an array of timestamps with open, high, low, and close prices, along with volume and swap data. Here’s what it can look like:

{
  //...
  result: (
    {
      timestamp: '2025-01-01T00:00:00.000Z',
      open: 3331.696480420306,
      high: 3356.4217239746795,
      low: 3331.5069326442967,
      close: 3356.4217239746795,
      volume: 3528532.8710554917,
      trades: 234
    },
    //...
  )
}

Summary: Embed Crypto Search – How to Build a Crypto Search Bar

Building a crypto search bar for your project is easier said than done. It requires real-time indexing, cross-chain support, ranking systems, and more. Fortunately, you can now use Moralis’ Token Search API to side-step all underlying complexities, allowing you to build and embed a crypto search bar in minutes!

Text: "Summary: Embed Crypto Search - How to Build a Crypto Search Bar"

The Token Search API provides real-time, verified token searches across all chains, giving you the tools to find assets by name, symbol, or address. Here are some key benefits and features of this premier tool: 

  • Cross-Chain Support: Find tokens across all major EVM chains and the Solana network.



  • Filtered Results: Filter by chain for quick, specific results.



  • Smart Search: Search for tokens by name, symbol, address, or pair address.



  • In-Depth Metadata: Get detailed metadata for all tokens, including prices, market cap, liquidity change, holders, etc. 

If you’re looking for the best and easiest way to build and embed a crypto search bar, be sure to sign up with Moralis right now!

Want to see how Moralis stacks up against other API providers? For example, check out our comparison guide diving into the DEXScreener API!

 



Source link

Draugai: - Marketingo paslaugos - Teisinės konsultacijos - Skaidrių skenavimas - Fotofilmų kūrimas - Karščiausios naujienos - Ultragarsinis tyrimas - Saulius Narbutas - Įvaizdžio kūrimas - Veidoskaita - Nuotekų valymo įrenginiai -  Padelio treniruotės - Pranešimai spaudai -