To fetch an NFT's Rarity Score you can either call Fetch Nft By Address or List Collection Nfts to get information on individual NFTs. Inside each NFT, if an NFT has a rarity score, it will be present in the rarity_score
key.
An NFT may, or may not, have a Rarity Score
In the event your NFT doesn't have a rarity score, it won't be present in the information returned by the endpoint. In the case of the SDKs this value will come as None or null/undefined
You can also use the SDK to fetch this information like this:
import PulsarSDK, { ChainKeys } from 'pulsar_sdk_js'
const sdk = new PulsarSDK(API_KEY)
sdk.nfts.fetch_nft_by_address(ChainKeys.BSC, 'YOUR COLLECTION ADDRESS', 'YOUR NFT TOKEN ID').then((nft_item) => {
const { rarity_score } = nft_item
console.log(rarity_score)
})
from pulsar_sdk_py import PulsarSDK
from pulsar_sdk_py.enums import ChainKeys
sdk = PulsarSDK(api_key=API_KEY)
nft_item = sdk.nfts.fetch_nft_by_address(
collection_address="YOUR NFT COLLECTION ADDRESS", chain=ChainKeys.TERRA2, token_id="YOUR TOKEN ID"
)
rarity_score = nft_item.rarity_score