summarizeNftAttributes - SDK

Get a summary of attribute prevalence for an NFT collection.

Don’t have an API key?

Start using this method in your app today. Get started for free

Description

Get a summary of attribute prevalence for an NFT collection.

Parameters

NameTypeDescription
contractAddressstringContract address for the NFT collection.

Response

PropertyTypeDescription
Promise<NftAttributesResponse>array of objectsAn array of objects containing nft metadata.

NftAttributesResponse object parameters

PropertyTypeDescription
contractAddressstringThe specified NFT contract’s address.
totalSupplynumberThe specified NFT contract’s total supply.
summarystringThe attribute prevalence of each trait grouped by the trait type for the provided NFT.

Example Request and Response

Prerequisite: You will need to install the Alchemy SDK before making requests with it.

The commands for installing it using npm or yarn are given below:

$npm install alchemy-sdk

Request

index.js
1// Imports the Alchemy SDK
2const { Alchemy, Network } = require("alchemy-sdk");
3
4// Configures the Alchemy SDK
5const config = {
6 apiKey: "alchemy-replit", // Replace with your API key
7 network: Network.ETH_MAINNET, // Replace with your network
8};
9
10// Creates an Alchemy object instance with the config to use for making requests
11const alchemy = new Alchemy(config);
12
13const main = async () => {
14 const collection = "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D";
15
16 //Call the method to fetch a summary a attribute prevalence for an NFT collection.
17 const response = await alchemy.nft.summarizeNftAttributes(collection)
18
19 //Logging the response to the console
20 console.log(response)
21};
22
23main();

Response

json
1{
2 summary: {
3 Fur: {
4 Tan: 626,
5 'Death Bot': 175,
6 Trippy: 77,
7 Brown: 1370,
8 Gray: 496,
9 'Golden Brown': 778,
10 Blue: 490,
11 Noise: 155,
12 Zombie: 302,
13 Cream: 636,
14 'Solid Gold': 46,
15 Dmt: 215,
16 Black: 1229,
17 Cheetah: 406,
18 'Dark Brown': 1352,
19 Red: 474,
20 Pink: 511,
21 White: 397,
22 Robot: 265
23 },
24 Eyes: {
25 Heart: 394,
26 Sleepy: 751,
27 Eyepatch: 333,
28 'X Eyes': 243,
29 Zombie: 308,
30 Angry: 432,
31 Coins: 479,
32 'Blue Beams': 49,
33 'Wide Eyed': 549,
34 Hypnotized: 220,
35 Bloodshot: 846,
36 Blindfold: 264,
37 Sunglasses: 352,
38 '3d': 487,
39 Bored: 1714,
40 'Laser Eyes': 69,
41 Cyborg: 108,
42 Crazy: 407,
43 Closed: 710,
44 Sad: 551,
45 Scumbag: 233,
46 Robot: 350,
47 Holographic: 151
48 },
49 Background: {
50 Gray: 1170,
51 Aquamarine: 1266,
52 Blue: 1242,
53 Purple: 1291,
54 Yellow: 1283,
55 'New Punk Blue': 1232,
56 'Army Green': 1243,
57 Orange: 1273
58 },
59 Mouth: {
60 'Phoneme Vuh': 333,
61 Discomfort: 208,
62 'Bored Unshaven Pipe': 101,
63 'Bored Cigarette': 710,
64 Rage: 266,
65 'Bored Bubblegum': 119,
66 'Bored Pizza': 50,
67 Grin: 713,
68 'Bored Party Horn': 88,
69 Bored: 2272,
70 'Bored Unshaven Bubblegum': 65,
71 'Bored Unshaven Cigarette': 438,
72 Jovial: 296,
73 'Tongue Out': 202,
74 'Grin Multicolored': 116,
75 'Small Grin': 272,
76 'Bored Unshaven Party horn': 45,
77 'Phoneme ooo': 255,
78 'Bored Unshaven': 1551,
79 'Bored Unshaven Pizza': 26,
80 'Bored Unshaven Dagger': 28,
81 'Phoneme Wah': 163,
82 'Phoneme Oh': 237,
83 Dumbfounded: 505,
84 'Bored Pipe': 132,
85 'Grin Gold Grill': 91,
86 'Bored Unshaven Cigar': 94,
87 'Phoneme L': 241,
88 'Bored Unshaven Kazoo': 61,
89 'Grin Diamond Grill': 78,
90 'Bored Dagger': 49,
91 'Bored Cigar': 121,
92 'Bored Kazoo': 74
93 },
94 Hat: {
95 "Trippy Captain's Hat": 65,
96 'Bayc Flipped Brim': 231,
97 'Short Mohawk': 318,
98 Safari: 182,
99 'Cowboy Hat': 354,
100 "Sea Captain's Hat": 304,
101 'Vietnam Era Helmet': 223,
102 'Sushi Chef Headband': 187,
103 'Irish Boho': 225,
104 "Girl's Hair Short": 150,
105 'Laurel Wreath': 72,
106 "Girl's Hair Pink": 105,
107 'Bayc Hat Red': 119,
108 Horns: 252,
109 "Fisherman's Hat": 345,
110 Bowler: 262,
111 'Spinner Hat': 181,
112 'Faux Hawk': 136,
113 "Seaman's Hat": 420,
114 'Ww2 Pilot Helm': 110,
115 'Party Hat 1': 120,
116 'Party Hat 2': 107,
117 Beanie: 578,
118 "King's Crown": 77,
119 'Army Hat': 294,
120 'Commie Hat': 304,
121 'Bunny Ears': 195,
122 'S&m Hat': 235,
123 'Stuntman Helmet': 157,
124 Fez: 377,
125 'Bandana Blue': 89,
126 'Bayc Hat Black': 228,
127 Halo: 324,
128 'Police Motorcycle Helmet': 130,
129 'Prussian Helmet': 130,
130 "Baby's Bonnet": 158
131 }
132 },
133 totalSupply: 10000,
134 contractAddress: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d'
135}

Use Cases

Here is a potential use case for the summarizeNftAttributes method:

  • Users can use the summarizeNftAttributes method to get an overview of all the traits in an NFT Collection and also find out which traits are rare.