Get NFT Metadata
info
ChainQuery API is currently in beta. Report any bugs to support@nirvanalabs.ai
Type
GET
Description
Retrieves the metadata (image and attributes) plus calculates the rarity rank and rarity score for any ERC721 NFT.
Parameters
address
: NFT Contract addresstoken_id
: NFT token id
Response
image
: Image URL or IPFS URI for asset (This can also be other file types other than images)attributes
:trait_type
: Describes the name of the attribute traitvalue
: The value of the attribute trait (This can be a number or string)total
: Total token supply (# of minted tokens - # of burned tokens)rarity_total
: The rarity rank of the NFT out of the entire token supplyrarity_score
: A universal rarity score to compare NFT rarities across collections
Code
- Curl (HTTP)
- JavaScript
- Ruby
- Python
curl --location --request GET 'https://api.nirvanalabs.xyz/nft/metadata?address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&token_id=4002'
var axios = require('axios');
var config = {
method: 'get',
url: 'https://api.nirvanalabs.xyz/nft/metadata?address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&token_id=4002',
headers: { }
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
require "uri"
require "net/http"
url = URI("https://api.nirvanalabs.xyz/nft/metadata?address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&token_id=4002")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
response = https.request(request)
puts response.read_body
import http.client
conn = http.client.HTTPSConnection("api.nirvanalabs.xyz")
payload = ''
headers = {}
conn.request("GET", "/nft/metadata?address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d&token_id=4002", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Sample Response
[
{
"image": "ipfs://QmaNd8sZCj8i1c6TUkxK3ZVMwYqRUADWPwMyraY7ECAaZM",
"attributes": [
{
"trait_type": "Hat",
"value": "Commie Hat",
"total": 9999,
"rarity_total": 304,
"rarity_score": 32.89144736842105
},
{
"trait_type": "Background",
"value": "Purple",
"total": 9999,
"rarity_total": 1291,
"rarity_score": 7.745158791634392
},
{
"trait_type": "Fur",
"value": "Golden Brown",
"total": 9999,
"rarity_total": 778,
"rarity_score": 12.852185089974293
},
{
"trait_type": "Earring",
"value": "Silver Hoop",
"total": 9999,
"rarity_total": 881,
"rarity_score": 11.349602724177071
},
{
"trait_type": "Clothes",
"value": "Navy Striped Tee",
"total": 9999,
"rarity_total": 334,
"rarity_score": 29.937125748502996
},
{
"trait_type": "Mouth",
"value": "Bored",
"total": 9999,
"rarity_total": 2272,
"rarity_score": 4.400968309859155
},
{
"trait_type": "Eyes",
"value": "Crazy",
"total": 9999,
"rarity_total": 407,
"rarity_score": 24.56756756756757
},
{
"trait_type": "__TRAIT_COUNT__",
"value": 7,
"total": 9999,
"rarity_total": 1883,
"rarity_score": 5.310143388210303
}
]
}
]