Cover Image for Exploring NFT Sales with Bitquery NFT API: Insights, Queries, and Real-Time Data

Exploring NFT Sales with Bitquery NFT API: Insights, Queries, and Real-Time Data

NFT

If you're a developer working on NFT projects or an NFT collector looking to buy new NFTs, you need information to make smart choices. In this article, we'll explore NFT sales data using the Bitquery NFT API. This tool helps us get details about NFT transfers, trades, and more.

NFT sales data shows us where people are spending their money. We can learn a lot from it, but let's start by understanding how to ask for NFT sales data. Once you know how to do that, you can discover valuable insights on your own.

Let’s write some queries to query NFT data from Ethereum using Bitquery NFT API.

Historical NFT Sales

Historical NFT sales data gives us insights into what has been trend for the whole NFT ecosystem. Let’s write a query to get historical NFT sales data from the Seaport Protocol by Opensea.

Historical NFT Sales

In this query, we are going to query all the NFT sales that happened after Jan 01, 2023 on Seaport protocol which is created by Opensea as a which new web3 marketplace protocol for safely and efficiently buying and selling NFTs.

To query from Seaport, we have to set ProtocolName value to seaport_v1.4.

Open the query in the IDE.

{
  EVM(dataset: combined, network: eth) {
    DEXTradeByTokens(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Currency: {Fungible: false}, Dex: {ProtocolName: {is: "seaport_v1.4"}}}}
    ) {
      Block {
        Time
      }
      Trade {
        Amount
        Buyer
        Currency {
          Name
          SmartContract
        }
        Dex {
          ProtocolName
          SmartContract
        }
        Price
        Seller
        Side {
          Amount
          Currency {
            Name
            ProtocolName
          }
          Type
          Buyer
          Seller
          URIs
        }
        Sender
      }
      Transaction {
        Hash
      }
    }
  }
}

Top 10 Trades of Last Year

We can also filter sales data, find what were the largest trade by changing the descending field of orderBy filter to Trade_Side_Amount.

Open the query in the IDE.

{
  EVM(dataset: combined, network: eth) {
    DEXTradeByTokens(
      limit: {count: 10}
      orderBy: {descending: Trade_Side_Amount}
      where: {Trade: {Currency: {Fungible: false}, Dex: {ProtocolName: {is: "seaport_v1.4"}}}}
    ) {
      Block {
        Time
      }
      Trade {
        Amount
        Buyer
        Currency {
          Name
          SmartContract
        }
        Dex {
          ProtocolName
          SmartContract
        }
        Price
        Seller
        Side {
          Amount
          Currency {
            Name
            ProtocolName
          }
          Type
          Buyer
          Seller
          URIs
        }
        Sender
      }
      Transaction {
        Hash
      }
    }
  }
}

Also Read: Opensea NFT API - A Complete Developer Guide

NFT Sales by Collection

If you’re buying an NFT most probably it will be part of a collection like Bored Ape Yacht Club, CryptoPunks, or Doodles, etc. When buying, we can make decisions based on sales trends to figure out what is the best value for money.

Let’s write some queries to get NFT sales by collection. We will also try to query what are the top collections by sales.

BAYC NFT Sales

BAYC or Bored Ape Yacht Club is one of the most popular collection. So let’s write a query to get NFT sales after Jan 01, 2023.

To specifically query sales from a collection, we have to add address of BAYC contract (0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d) to SmartContract field of Currency filter.

Open the query in the IDE.

{
  EVM(network: eth, dataset: combined) {
    DEXTradeByTokens(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Currency: {Fungible: false, SmartContract: {is: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"}}, Dex: {ProtocolName: {is: "seaport_v1.4"}}}, Block: {Date: {after: "2023-01-01"}}}
    ) {
      Block {
        Time
      }
      Trade {
        Amount
        Buyer
        Currency {
          Name
          ProtocolName
          SmartContract
        }
        Dex {
          ProtocolFamily
          SmartContract
          ProtocolName
          ProtocolVersion
        }
        Ids
        Price
        Seller
        Side {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Type
        }
        URIs
      }
      Transaction {
        Hash
      }
    }
  }
}

Trending NFT collection by Sales

We can also query trending collections by checking number of sales for a collection.

Open this query in the IDE.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      orderBy: {descendingByField: "count"}
      limit: {count: 10}
      where: {Trade: {Buy: {Currency: {Fungible: false}}}, Block: {Date: {after: "2023-08-20"}}}
    ) {
      count
      sum(of: Trade_Sell_Amount)
      Trade {
        Buy {
          Currency {
            Name
            SmartContract
          }
        }
      }
    }
  }
}

NFT Sales on different Marketplaces

In above section, we have seen NFT sales from Seaport protocol by Opensea but Bitquery NFT API also provides other marketplaces like LooksRare, Blur and many more. Let’s see how to get sales from other protocols or marketplace.

NFT sales by particular marketplace

We will write a query to get NFT sales after August 01, 2023, on Blur NFT marketplace.

For this query, we need to change the protocol name to blur_v1 and query will return all the NFT sales from Blur V1.

Open this query in the IDE.

{
  EVM(network: eth, dataset: combined) {
    DEXTradeByTokens(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Currency: {Fungible: false}, Dex: {ProtocolName: {is: "blur_v1"}}}, Block: {Date: {after: "2023-08-01"}}}
    ) {
      Block {
        Time
      }
      Trade {
        Amount
        Buyer
        Currency {
          Name
          ProtocolName
          SmartContract
        }
        Dex {
          ProtocolFamily
          SmartContract
          ProtocolName
          ProtocolVersion
        }
        Ids
        Price
        Seller
        Side {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Type
        }
        URIs
      }
      Transaction {
        Hash
      }
    }
  }
}

Also Read: BLUR NFT Marketplace API

NFT Trade Volumes

NFT Trade Volume is the total amount of sales that happened for a particular collection in a given timeframe. We can get NFT trade volume using NFT API, so let’s write a query to NFT trade volume.

Total NFT Trade Volume for collection

In this query, we will get NFT trade volume for BAYC which were traded in Ethereum. This way we will have BAYC trade volume in ETH.

We will fitler data using address of BAYC smart contract which is 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D along with currency name to Ethereum for Trade filter.

Open this query in the IDE.

{
  EVM(network: eth, dataset: combined) {
    DEXTradeByTokens(
      where: {Trade: {Currency: {Fungible: false, HasURI: true, SmartContract: {is: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"}}, Dex: {ProtocolName: {is: "seaport_v1.4"}}, Side: {Currency: {Name: {is: "Ethereum"}}}}}
    ) {
      sum(of: Trade_Side_Amount)
    }
  }
}

Daily NFT volume for Opensea

We can also get volume by a specific time interval, which we can set to whatever we want. Here we will get daily volume of Seaport protocol by Opensea.

To set time interval, we will set value of interval field of Block.Time to days so that we can get daily volume of NFT sales.

Open this query in the IDE.

{
  EVM(network: eth, dataset: combined) {
    DEXTradeByTokens(
      orderBy: {descending: Block_Time}
      where: {Trade: {Currency: {Fungible: false}, Dex: {ProtocolName: {is: "seaport_v1.4"}}, Side: {Currency: {Name: {is: "Ethereum"}}}}}
    ) {
      sum(of: Trade_Side_Amount)
      Block {
        Time(interval: {in: days})
      }
    }
  }
}

Also Read: Bitquery NFT Marketplace APIs: How to get NFT Data

Real Time NFT Sales

We can also get data in real-time using GraphQL subscriptions with Bitquery API. Let’s see how to write queries for getting real-time data.

Real-Time NFT Trades

We have already seen how to query NFT trade in above sections. To get data in real-time, we will need to write queries that start with subscription keyword, which creates a WebSocket connection with server which sends us latest data.

Open this query in the IDE.

subscription {
  EVM(network: eth) {
    DEXTradeByTokens(where: {Trade: {Dex: {ProtocolName: {is: "seaport_v1.4"}}}}) {
      Block {
        Time
      }
      Trade {
        Amount
        Buyer
        Currency {
          Name
          SmartContract
        }
        Dex {
          ProtocolFamily
          ProtocolName
          ProtocolVersion
          SmartContract
        }
        Ids
        Price
        Seller
        Side {
          Amount
          Buyer
          Currency {
            Name
            ProtocolName
            SmartContract
            Symbol
          }
          Ids
          Type
        }
      }
    }
  }
}

Filter real-time NFT data

We can also add different filter to filter the data we are getting in real-time. All the filters, we have used in above queries will work in subscriptions.

If you want to use the real-time data in your application, you can check example code snippet which shows how to use websockets using python.

Also Read: Track Events like NFT Drop, ENS Registration with Bitquery NFT API

Conclusion

We have seen how to query data related to NFT sales using Bitquery API using queries to get historical data and subscriptions to get real-time data. We have written queries to get a lot of different data points related to NFT sales.

This was a article to see what kind of data you can get using Bitquery API. There are a lot of data different kind of data you can fetch using our API.

Even though, we have seen how to get the data, it’s your work to build meaningful applications using this data or find insights about NFT market in general. So you build something or do something cool with data provided by Bitquery API, let us know in our telegram we would love to see it.

About Bitquery

Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. Our products are:

  • Coinpath® APIs provide blockchain money flow analysis for more than 24 blockchains. With Coinpath’s APIs, you can monitor blockchain transactions, investigate crypto crimes such as bitcoin money laundering, and create crypto forensics tools. Read this to get started with Coinpath®.
  • Digital Assets API provides index information related to all major cryptocurrencies, coins, and tokens.
  • DEX API provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, Kyber Network, Airswap, Matching Network, etc.

If you have any questions about our products, ask them on our Telegram channel or email us at sales@bitquery.io. Also, subscribe to our newsletter below, we will keep you updated with the latest in the cryptocurrency world.

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.