Sunday, July 13, 2025
No Result
View All Result
Blockchain Broadcast
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • NFT
  • Blockchain
  • Metaverse
  • DeFi
  • Web3
  • Analysis
  • Regulations
  • Scam Alert
Crypto Marketcap
Blockchain Broadcast
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • NFT
  • Blockchain
  • Metaverse
  • DeFi
  • Web3
  • Analysis
  • Regulations
  • Scam Alert
No Result
View All Result
Blockchain Broadcast
No Result
View All Result

NFT Rarity API – How to Get an NFT’s Rarity Ranking – Moralis Web3

September 6, 2024
in Web3
Reading Time: 14 mins read
0 0
A A
0
Home Web3
Share on FacebookShare on Twitter


In search of the simplest strategy to get an NFT’s rarity rating? If that’s the case, you’ve come to the best place. In in the present day’s information, we’ll introduce you to Moralis’ NFT Rarity API. This progressive interface introduces a number of new endpoints and enriches our API responses with complete NFT rarity knowledge. As such, now you can question an NFT’s rarity rating with a single request. Are you desirous to find out how this works? Take a look at the pattern script beneath, the place we fetch the metadata of an NFT:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/nft/0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB/1?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for calling the endpoint above, you’ll get the metadata of the required NFT. Right here’s a pattern response: 

{
quantity: ‘1’,
token_id: ‘1’,
token_address: ‘0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb’,
contract_type: ‘CRYPTOPUNKS’,
owner_of: ‘0xffa914c83d851b9fe372e4ba6a6e131373aa16ab’,
last_metadata_sync: ‘2024-09-05T08:44:23.476Z’,
last_token_uri_sync: ‘2024-09-05T08:44:23.393Z’,
metadata: ‘{“picture”:”https://www.larvalabs.com/cryptopunks/cryptopunk001.png”,”title”:”CryptoPunk 001″,”attributes”:[“Smile”,”Mohawk”],”description”:”Male”}’,
block_number: ‘16079985’,
block_number_minted: null,
title: ‘CRYPTOPUNKS’,
image: ‘Ͼ’,
token_hash: ‘a99d02058e62e327e79aabd57e0b88a3’,
token_uri: ‘Invalid uri’,
minter_address: null,
rarity_rank: 7247,
rarity_percentage: 72.47,
rarity_label: ‘Prime 73%’,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/BdxvLseXcfl57BiuQcQYdJ64v-aI8din7WPk0Pgo3qQFhAUH-B6i-dCqqc_mCkRIzULmwzwecnohLhrcH8A9mpWIZqA7ygc52Sr81hE?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gae/48oVuDyfe_xhs24BC2TTVcaYCX7rrU5mpuQLyTgRDbKHj2PtzKZsQ5qC3xTH4ar34wwAXxEKH8uUDPAGffbg7boeGYqX6op5vBDcbA?w=500&auto=format’
}

Along with metadata, the response comprises three key rarity parameters: rarity_rank, rarity_percentage, and rarity_label:

//…
rarity_rank: 7247,
rarity_percentage: 72.47,
rarity_label: ‘Prime 73%’,
//…

That’s it; fetching an NFT’s rarity is easy when working with Moralis. Nonetheless, if you would like a extra in-depth rationalization of how this works, be part of us in in the present day’s information as we lay all of it out for you. 

Are you keen to begin leveraging our APIs your self? Don’t neglect to enroll with Moralis. You’ll be able to arrange your account free of charge, and also you’ll acquire rapid entry to our APIs and premier RPC nodes! 

Overview

The idea of rarity is essential for the NFT market because it impacts the worth of particular person tokens and drives demand. Nonetheless, figuring out the rarity of a token is less complicated mentioned than carried out, as you want a stable system to find out an NFT’s uniqueness. And developing with a system is a tedious and time-consuming process. Fortuitously, it’s with this in thoughts that we launched our NFT Rarity API.

With Moralis’ NFT Rarity API, now you can effortlessly get any NFT’s rarity rating with a single API request. However how does this work? How is our rarity rating calculated? And what endpoints are supported? For the solutions to those questions, tag alongside on this tutorial. Let’s dive straight in! 

What’s NFT Rarity?

NFT rarity refers back to the uniqueness of an NFT inside a selected assortment, which is often decided by how frequent or unusual the token’s attributes/traits are. In NFT collections, sure traits or traits – resembling background, shade, equipment, and so forth. – could be extra uncommon than others. The much less ceaselessly a trait happens, the rarer and doubtlessly extra useful the NFT is taken into account to be. 

What is NFT rarity?

However why does NFT rarity matter? 

NFT rarity performs an important function within the worth and desirability of tokens. Collectors, buyers, and crypto fans usually seek for NFTs with uncommon traits, as they often maintain better worth in the long run. 

Whereas rarity could be calculated in a number of methods, it usually entails analyzing the frequency of sure traits throughout your complete assortment. Based mostly on this, a rarity rating is assigned, and every NFT is ranked accordingly. 

All in all, the idea of NFT rarity is key to the market, driving demand and affecting the worth of particular person NFTs! 

Introducing Moralis’ NFT Rarity API – The Best Solution to Get an NFT’s Rarity Rating

With Moralis’ introduction of the NFT Rarity API, now you can seamlessly get an NFT’s rarity rating with out breaking a sweat. The NFT Rarity API introduces a number of new endpoints and enriches our API responses with rarity-related knowledge. As such, when querying NFT balances, metadata, collections, and so forth., you’ll mechanically get the rarity rating of all NFTs!

Moralis NFT Rarity API.

The NFT Rarity API assigns every NFT three key parameters:

rarity_rank: A numerical rank based mostly on the NFT’s rarity rating.

rarity_percentage: A share indicating the token’s rarity relative to your complete assortment.

rarity_label: A label describing how uncommon the NFT is (e.g., “Prime 5% rarity”).

All in all, the NFT Rarity API makes it simple so that you can seamlessly question an NFT’s rarity rating with only a single API name!

How is the Rarity Rating Calculated?

Moralis’ NFT rarity algorithm is a custom-designed technique that calculates the rarity of any given token inside a set with precision. The algorithm elements within the complete variety of tokens within the assortment, the variety of copies of the NFT, and the traits that contribute to an NFT’s uniqueness. The components assigns a numerical worth to every trait, which is then added collectively to find out the general rarity rating. 

Calculating NFT rarity ranking.

Inside an NFT assortment, every trait is analyzed and assigned the next three: 

depend: The full variety of occurrences of this attribute/trait. 

share: The proportion of tokens that possess the attribute/trait. 

rarity_label: A label displaying the rarity based mostly on the share (e.g., ”Prime 5% trait”).

From there, every NFT is then assigned the parameters described within the earlier part: 

rarity_rank

rarity_percentage

rarity_label

What Collections Does the NFT Rarity API Assist?

The NFT Rarity API helps ERC-721 and ERC-1155 collections with a most restrict of fifty,000 tokens. Rarity calculations are solely carried out when the circumstances beneath are met: 

The gathering’s contract follows the ERC-721 or ERC-1155 requirements. 

The variety of NFTs within the assortment is fewer than 50,000.

The metadata and traits for all tokens within the assortment have been requested. 

What Endpoints Does the NFT Rarity API Cowl?

Right here’s a listing of recent endpoints which are obtainable: 

/nft/:handle/traits: Get NFT traits by assortment (one response, restricted to five,000 traits). 

/nft/:handle/traits/paginate: Fetch NFT traits by assortment (paginated, no restrict).

/nft/:handle/nfts-by-traits: Get NFTs by traits.

/nft/:handle/traits/resync: Resync NFT traits by assortment. 

NFT rarity knowledge has been added to the next endpoints: 

/:handle/nfts: Get NFTs by pockets.

/nft/:handle: Fetch NFTs by assortment.

/nft/:handle/house owners: Question NFT house owners by assortment.

/nft/:handle/:token_id/house owners: Get NFT house owners by token id. 

/nft/:handle/:token_id: Fetch NFT metadata. 

Take a look at the NFT Rarity documentation web page to study extra! 

Full Tutorial: How you can Get an NFT’s Rarity Rating in 3 Steps

We’ll now stroll you thru a tutorial on find out how to get an NFT’s rarity utilizing the Moralis NFT Rarity API. With this premier function, you’ll be able to simply get the info you want in three easy steps:

Get a Moralis API Key

Write a Script Calling the getNFTMetadata Endpoint

Run the Code

Nonetheless, earlier than transferring on, you’ll want to care for a few conditions. 

Stipulations

Earlier than persevering with with step one, guarantee you have got the next prepared:

Step 1: Get a Moralis API Key

Click on the ”Begin for Free” button on the high proper and arrange your Moralis account: 

Red arrow pointing at "Start for Free" button.

When you log in, you’ll discover your API key immediately underneath the ”Residence” tab: 

Red arrow pointing at copy button for API key.

Copy and hold the important thing for now, as you’ll want it within the following step.

Step 2: Write a Script Calling the getNFTMetadata Endpoint

Launch your most popular IDE, arrange a folder, and initialize your challenge with the next terminal command:

npm init

Set up the required dependencies by operating the instructions beneath in your terminal:

npm set up node-fetch –save
npm set up moralis @moralisweb3/common-evm-utils

Add “sort”: “module” to your ”package deal.json” file:

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

Create an ”index.js” file and add the next code:

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/nft/0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB/1?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Exchange YOUR_API_KEY with the important thing you copied throughout step one, and configure the handle and tokenId parameters:

Red arrows pointing at YOUR_API_KEY and address parameter.

Step 3: Run the Code

Execute the next terminal command in your challenge’s root folder to run the code: 

node index.js

In return, you’ll get the metadata of the required NFT. Right here’s a pattern response: 

{
quantity: ‘1’,
token_id: ‘1’,
token_address: ‘0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb’,
contract_type: ‘CRYPTOPUNKS’,
owner_of: ‘0xffa914c83d851b9fe372e4ba6a6e131373aa16ab’,
last_metadata_sync: ‘2024-09-05T08:44:23.476Z’,
last_token_uri_sync: ‘2024-09-05T08:44:23.393Z’,
metadata: ‘{“picture”:”https://www.larvalabs.com/cryptopunks/cryptopunk001.png”,”title”:”CryptoPunk 001″,”attributes”:[“Smile”,”Mohawk”],”description”:”Male”}’,
block_number: ‘16079985’,
block_number_minted: null,
title: ‘CRYPTOPUNKS’,
image: ‘Ͼ’,
token_hash: ‘a99d02058e62e327e79aabd57e0b88a3’,
token_uri: ‘Invalid uri’,
minter_address: null,
rarity_rank: 7247,
rarity_percentage: 72.47,
rarity_label: ‘Prime 73%’,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/BdxvLseXcfl57BiuQcQYdJ64v-aI8din7WPk0Pgo3qQFhAUH-B6i-dCqqc_mCkRIzULmwzwecnohLhrcH8A9mpWIZqA7ygc52Sr81hE?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gae/48oVuDyfe_xhs24BC2TTVcaYCX7rrU5mpuQLyTgRDbKHj2PtzKZsQ5qC3xTH4ar34wwAXxEKH8uUDPAGffbg7boeGYqX6op5vBDcbA?w=500&auto=format’
}

As you’ll be able to see, the response comprises three parameters that we’re significantly desirous about: rarity_rank, rarity_percentage, and rarity_label: 

//…
rarity_rank: 7247,
rarity_percentage: 72.47,
rarity_label: ‘Prime 73%’,
//…

Congratulations! You now know find out how to get an NFT’s rarity rating utilizing our NFT Rarity API! 

NFT Rarity API Use Instances

The NFT Rarity API has many use circumstances, as many platforms can profit from NFT rarity-related knowledge. Listed here are three key examples: 

Web3 Video games: NFT-based Web3 video games can profit from rarity-related knowledge, giving customers higher perception into how distinctive their in-game belongings/gadgets really are. 

NFT Marketplaces: With rarity rankings, it’s potential for NFT marketplaces to present customers higher perception into the individuality of NFTs being traded on the platform. This can assist merchants make extra knowledgeable funding selections.

Token Analytics: Token analytics platforms may give customers deeper perception into the worth of NFTs with our NFT Rarity API. 

NFT rarity API use cases.

The use circumstances above are solely three examples, and the NFT Rarity API can be helpful for many platforms that want entry to NFT knowledge! 

Past the NFT Rarity API – Exploring Moralis’ APIs & RPC Nodes

Moralis is the main knowledge supplier throughout the crypto area. In our suite of growth instruments, you’ll discover next-generation RPC nodes and a number of use case-specific APIs, together with the Pockets API, Token API, Streams API, and so forth. As such, when utilizing Moralis, you get all crypto knowledge in a single place.

Moralis logo.

However what makes Moralis particular? 

One Name – All of the Knowledge: With our APIs and Prolonged RPC Strategies, you get extra knowledge with fewer calls. Fetch a pockets’s full historical past, token balances with costs, and far more with single requests. 

Really Cross-Chain: Moralis helps all main chains, together with Ethereum, Base, Optimism, BNB Sensible Chain (BSC), and lots of extra. Expertise full function parity throughout these networks so you’ll be able to streamline your developer expertise. 

Enterprise-Grade Safety: Moralis is SOC 2 Sort 2 licensed, highlighting our dedication to top-tier safety and reliability. 

Now, let’s dive deeper into our suite of growth instruments, beginning with the APIs.

Web3 APIs

Our suite of Web3 APIs consists of a number of use case-specific interfaces. Listed here are three key examples: 

Pockets API: The Pockets API is a premier software for constructing wallets and integrating pockets performance into dapps. Use this interface to fetch any pockets’s full historical past, internet value, profitability, token balances, and far more. 

Token API: Moralis’ Token API is your go-to software for ERC-20 knowledge, supporting each single token throughout all main chains. Get token balances, transactions, costs, and extra with one API name. 

Streams API: The Streams API is the {industry}’s main real-time knowledge answer. Arrange Web3 knowledge pipelines on the click on of a button to stream knowledge immediately into the backend of your dapps as quickly as on-chain occasions happen. 

Take a look at the Web3 API web page to study extra about all our interfaces! 

RPC Nodes

With Moralis’ premier node service, now you can seamlessly entry RPC nodes for all main chains on the click on of some buttons. Supported chains embody Ethereum, Polygon, Base, Optimism, and lots of extra! 

What makes our RPC nodes distinctive? 

Velocity: Our RPC nodes are lightning-fast, with response instances from 70 ms. 

Reliability: Expertise 99.9% reliability with Moralis’ RPC nodes.

Prolonged RPC Strategies: With our Prolonged RPC Strategies, now you can seamlessly question decoded, human-readable knowledge together with your nodes. 

To study extra about this, try our RPC nodes web page! 

Abstract: NFT Rarity API – How you can Get an NFT’s Rarity Rating

NFT rarity is a vital idea for the NFT market, driving demand and influencing the worth of particular person tokens. Nonetheless, it’s fairly difficult to find out the rarity of an NFT, as you’ll want to examine traits in collections, rank these traits, and assign a rating. We all know the struggles of doing so, which is why we launched our NFT Rarity API! 

NFT Rarity API Summary

The NFT Rarity API makes it simple for anybody to seamlessly question trait knowledge and entry rarity rankings for ERC-721 and ERC-1155 NFT collections. As such, it’s now simpler than ever to get an NFT’s rarity rating. 

To display the accessibility of this premier function, try this pattern script displaying you ways simple it’s to fetch the rarity rating of an NFT: 

import fetch from ‘node-fetch’;

const choices = {
technique: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/nft/0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB/1?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for calling the script above, you’ll get the metadata of the required NFT. Right here’s a pattern response: 

{
quantity: ‘1’,
token_id: ‘1’,
token_address: ‘0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb’,
contract_type: ‘CRYPTOPUNKS’,
owner_of: ‘0xffa914c83d851b9fe372e4ba6a6e131373aa16ab’,
last_metadata_sync: ‘2024-09-05T08:44:23.476Z’,
last_token_uri_sync: ‘2024-09-05T08:44:23.393Z’,
metadata: ‘{“picture”:”https://www.larvalabs.com/cryptopunks/cryptopunk001.png”,”title”:”CryptoPunk 001″,”attributes”:[“Smile”,”Mohawk”],”description”:”Male”}’,
block_number: ‘16079985’,
block_number_minted: null,
title: ‘CRYPTOPUNKS’,
image: ‘Ͼ’,
token_hash: ‘a99d02058e62e327e79aabd57e0b88a3’,
token_uri: ‘Invalid uri’,
minter_address: null,
rarity_rank: 7247,
rarity_percentage: 72.47,
rarity_label: ‘Prime 73%’,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/BdxvLseXcfl57BiuQcQYdJ64v-aI8din7WPk0Pgo3qQFhAUH-B6i-dCqqc_mCkRIzULmwzwecnohLhrcH8A9mpWIZqA7ygc52Sr81hE?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gae/48oVuDyfe_xhs24BC2TTVcaYCX7rrU5mpuQLyTgRDbKHj2PtzKZsQ5qC3xTH4ar34wwAXxEKH8uUDPAGffbg7boeGYqX6op5vBDcbA?w=500&auto=format’
}

This response is enriched with three key parameters: rarity_rank, rarity_percentage, and rarity_label:

//…
rarity_rank: 7247,
rarity_percentage: 72.47,
rarity_label: ‘Prime 73%’,
//…

That’s it; getting an NFT’s rarity rating is that this simple, due to Moralis’ NFT Rarity API! 

Should you favored this NFT Rarity API article, think about studying extra guides right here on the Moralis weblog. For example, try our Tackle Labeling API information or discover ways to get token costs with an RPC node. 

Additionally, when you want to use the NFT Rarity API your self, don’t neglect to enroll with Moralis. You’ll be able to create an account freed from cost, and also you’ll get rapid entry to all our industry-leading growth instruments. 



Source link

Tags: APIMoralisNFTNFTsRankingRarityWeb3
Previous Post

Hoskinson slams proposal to burn 1.5 billion Cardano’s ADA tokens

Next Post

Ex-FTX Executive Accused in Chinese Bribery Scandal

Related Posts

Why Are So Many Crypto Games Shutting Down? Experts Weigh In
Web3

Why Are So Many Crypto Games Shutting Down? Experts Weigh In

July 13, 2025
GMX Hacker Goes White-Hat, Returns  Million—Sends Rest to Tornado Cash
Web3

GMX Hacker Goes White-Hat, Returns $40 Million—Sends Rest to Tornado Cash

July 11, 2025
Web3j Mentorship 2025: Meet the Mentees
Web3

Web3j Mentorship 2025: Meet the Mentees

July 11, 2025
Australia’s Tokenization Push Could Cement ‘Even Greater Financial Control’
Web3

Australia’s Tokenization Push Could Cement ‘Even Greater Financial Control’

July 10, 2025
Goblintown Heads to the Trenches With Solana Meme Coin Launch
Web3

Goblintown Heads to the Trenches With Solana Meme Coin Launch

July 9, 2025
Bitcoin Buying Sprees Accelerate as Metaplanet, Semler Stack More BTC
Web3

Bitcoin Buying Sprees Accelerate as Metaplanet, Semler Stack More BTC

July 7, 2025
Next Post
Ex-FTX Executive Accused in Chinese Bribery Scandal

Ex-FTX Executive Accused in Chinese Bribery Scandal

Bitcoin derivatives climb to 28% of liquid supply

Bitcoin derivatives climb to 28% of liquid supply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Facebook Twitter Instagram Youtube RSS
Blockchain Broadcast

Blockchain Broadcast delivers the latest cryptocurrency news, expert analysis, and in-depth articles. Stay updated on blockchain trends, market insights, and industry innovations with us.

CATEGORIES

  • Altcoin
  • Analysis
  • Bitcoin
  • Blockchain
  • Crypto Exchanges
  • Crypto Updates
  • DeFi
  • Ethereum
  • Metaverse
  • NFT
  • Regulations
  • Scam Alert
  • Uncategorized
  • Web3
No Result
View All Result

SITEMAP

  • About Us
  • Advertise With Us
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact Us

Copyright © 2024 Blockchain Broadcast.
Blockchain Broadcast is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
  • bitcoinBitcoin(BTC)$118,095.000.25%
  • ethereumEthereum(ETH)$2,964.700.11%
  • rippleXRP(XRP)$2.800.24%
  • tetherTether(USDT)$1.000.00%
  • binancecoinBNB(BNB)$691.520.06%
  • solanaSolana(SOL)$161.980.37%
  • usd-coinUSDC(USDC)$1.00-0.01%
  • dogecoinDogecoin(DOGE)$0.198555-1.02%
  • tronTRON(TRX)$0.302642-0.15%
  • staked-etherLido Staked Ether(STETH)$2,963.260.22%
No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • NFT
  • Blockchain
  • Metaverse
  • DeFi
  • Web3
  • Analysis
  • Regulations
  • Scam Alert

Copyright © 2024 Blockchain Broadcast.
Blockchain Broadcast is not responsible for the content of external sites.