Skip to main content

Getting Collection Data

Use the Zora API to get NFT collection data#

This guide will cover how to retrieve NFT collection data for Monarchs.
Data can be retrieved for any collection by using these queries and updating the collectionAddress.

note

GraphiQL Playground: https://api.zora.co/graphql

Monarchs Contract: 0xc729Ce9bF1030fbb639849a96fA8BBD013680B64

A collection is a group of NFTs that all share a single contract.


Getting a Collection Preview#

First off, we can begin by getting a preview of Monarchs by using the collections query. This query can fetch data for either multiple NFT collections or a specific collection.

query CollectionInfo {  collections(networks: [{network: ETHEREUM, chain: MAINNET}],               pagination: {limit: 8},               sort: {sortKey: CREATED, sortDirection: ASC},              where: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"})   {    nodes {      address      name      symbol      totalSupply    }  }}

Collection Stats#

Now let's look at a few general collection stats for Monarchs. Below we are using the aggregateStat query to get the information we need.

ownerCount

We can see that 888 total Monarchs that are held by 600 different addresses and the collection has done over 2251 ETH (chainTokenPrice) in sales volume across all markets.

query MonarchCollectionStats {  aggregateStat {    nftCount(where: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"})    ownerCount(where: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"})    salesVolume(where: {collectionAddresses: ["0x335eeef8e93a7a757d9e7912044d9cd264e2b2d8"]}, networks: [{network: ETHEREUM, chain: MAINNET}]) {      usdcPrice      totalCount      chainTokenPrice    }  }}

Minting History#

Next, let's look at the first NFT that was ever minted from this collection. We can see that it was minted on November 6th, 2021 for 0 ETH. A deeper dive will tell you that this is the creator's wallet and they were able to mint the first 20 Monarchs for free.

query FirstMonarchMinted {  mints(where: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"},         pagination: {limit: 1},         sort: {sortKey: TIME,         sortDirection: ASC}) {    nodes {      token {        tokenId        owner        mintInfo {          originatorAddress          price {            chainTokenPrice {              decimal            }          }          mintContext {            transactionHash            blockTimestamp          }        }      }    }  }}

note

One thing to call out is that sometimes collections will airdrop their tokens to people to trick certain interfaces into making it look like that address minted from the collection. A way to prevent this is to compare the originatorAddress with the toAddress.

The originatorAddress is the address that submitted the transaction and the toAddress is the address where the minted NFT was sent to in the transaction.

However, if we set the tokenId in where to 20 we can view the 21st Monarch minted and see that it was minted for 0.8 ETH.

query TwentyFirstMonarchMinted {  mints(where:         {tokens: {address: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64", tokenId: "20"}},         pagination: {limit: 1},         sort: {sortKey: TIME, sortDirection: ASC}) {    nodes {      token {        tokenId        owner        mintInfo {          originatorAddress          price {            nativePrice {              decimal            }          }          mintContext {            transactionHash            blockTimestamp          }        }      }    }  }}

Highest Sales#

By using the sales query and sorting by descending ETH_PRICE we can see the largest sales for Monarchs. We can see that the largest sale was tokenId 624 for 8.88 ETH on October 6th, 2021.

query TopMonarchSales {  sales(where: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"}, pagination: {limit: 3}, sort: {sortKey: NATIVE_PRICE, sortDirection: DESC}) {    nodes {      sale {        saleType        saleContractAddress        buyerAddress        sellerAddress        tokenId        transactionInfo {          blockTimestamp          transactionHash        }        price {          usdcPrice {            decimal          }          nativePrice {            decimal          }        }      }    }  }}

Top Holders#

We can view who the Monarch whales are by using ownersByCount on aggregateStat. This will order the addresses that hold the most NFTs of a collection in descending order.

query TopHolders {  aggregateStat {    ownersByCount(where: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"},                   pagination: {limit: 5}) {      nodes {        owner        count      }    }  }}

Preview Tokens in a Collection#

Here we are able to get a list of NFTs within the Monarchs collection. You are able to make the preview as simple or complex as you would like. In this example we are getting 3 tokens from the collection using the tokens query and returning all the metadata for each token.

query PreviewTokens {  tokens(networks: [{network: ETHEREUM, chain: MAINNET}],          pagination: {limit: 3},          sort: {sortKey: MINTED, sortDirection: ASC},          where: {collectionAddresses: ["0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"]})   {    nodes {      token {        collectionAddress        tokenId        name        tokenUrl        metadata      }    }  }}

Getting Stats on Attributes#

Viewing the distribution of attributes can be done by using the aggregateAttributes query. This will return the value, percent, and count for every attribute if provided by the NFT. Note, that some on-chain NFTs don't have attributes directly in their metadata.

query AggregateAttributesByCollectionAddress {  aggregateAttributes(        where: {collectionAddresses: ["0xc729Ce9bF1030fbb639849a96fA8BBD013680B64"],     },         networks: [{network: ETHEREUM, chain: MAINNET}]    ) {    traitType    valueMetrics {      count      percent      value    }  }}

Search Collection by Keyword#

The Zora API can find any token or collection that contains a specific keyword. In this case, the query is searching for tokens in the Monarch collection that have the word "Venom". We can see here that "Venom" ends up being a type of Base Pattern for Monarchs.

query CollectionTextSearch {  search(pagination: {limit: 5},          query: {text: "Venom"},          filter: {collectionAddresses: "0xc729Ce9bF1030fbb639849a96fA8BBD013680B64",          entityType: TOKEN})  {    nodes {      entity {        ... on Token {          tokenId          owner          attributes {            traitType            value          }        }      }    }  }}