Cover Image for Opensea API - Developer Guide for NFT Data

Opensea API - Developer Guide for NFT Data

NFT
Polygon

Today we will discuss Opensea API (Seaport Data API) and how to get Opensea NFT marketplace trading and other data using Bitquery's NFT API.

OpenSea shifted to Seaport protocol. Therefore we will discuss some traits of Seaport later in the article; however, for now, we can use simple DEXTrades APIs to get NFT trades from Opensea.

Note: In the queries, you will notice `seaport_v1.4`` basically, it’s not only the 1.4 version of Seaport, but it includes all the versions of Seaport.

Newly Created NFTs on Ethereum

Before starting with Opensea, let’s first see the API to get newly created/minted NFTs on Ethereum. In the following API, we are getting nonfungible transfers from NULL Address (0x0000000000000000000000000000000000000000). Also, we are adding a date filter; it’s important as NULL Address contains so much data that it will be challenging to process them without a date filter.

{
  EVM(dataset: combined) {
    Transfers(
      orderBy: {descending: Block_Time}
      limit: {count: 100}
      where: {
        Transfer: {
          Sender: {
            is: "0x0000000000000000000000000000000000000000"
            }
          },
        Block: {
          Date: {
            after: "2023-06-01"
          }
        }
      }
    ) {
      Block {
        Date
        Number
      }
      Transfer {
        Amount
        Receiver
        Currency {
          Name
          SmartContract
        }
        Id
        URI
      }
      Transaction {
        Hash
      }
    }
  }
}

OpenSea Shared Storefront NFTs

When you create NFT directly on OpenSea, it mints as OpenSea Shared Storefront (OPENSTORE) token. Therefore, let’s see the query to the latest NFTs transfers OPENSTORE Token.

{
	EVM(dataset: combined) {
		Transfers(
			orderBy: { descending: Block_Time }
			limit: { count: 100 }
			where: {
				Transfer: {
					Currency: {
						SmartContract: {
							is: "0x495f947276749ce646f68ac8c248420045cb7b5e"
						}
					}
				}
				Block: { Date: { after: "2023-06-01" } }
			}
		) {
			Block {
				Date
				Number
			}
			Transfer {
				Amount
				Receiver
				Currency {
					Name
					SmartContract
				}
				Id
				URI
			}
			Transaction {
				Hash
			}
		}
	}
}

Additionally, also, check API to check the most transferred NFTs on Opensea. And if you want to know more about transfer and Metadata related NFT APIs, read this blog that delves into these details.

{
  EVM(dataset: combined) {
    Transfers(
      orderBy: {descendingByField: "count"}
      limit: {count: 10}
      where: {Transfer: {Currency: {SmartContract: {is: "0x495f947276749ce646f68ac8c248420045cb7b5e"}}}}
    ) {
      count
      Transfer {
        Id
        Currency {
          Name
          SmartContract
        }
      }
    }
  }
}

Latest NFT Trades on OpenSea

In the following query, we are getting the latest Opensea trades by tracking the Seaport protocol (Here seaport_v1.4 means all versions of Seaport) and all transactions sent to Opensea’s seaport contract [0x00000000000000adc04c56bf30ac9d3c0aaf14dc](https://explorer.bitquery.io/ethereum/smart_contract/0x00000000000000adc04c56bf30ac9d3c0aaf14dc).

Actually, you can check any Marketplace NFT trades just by changing. Transaction -> To to the marketplace contract. Additionally, you can use this query to see who is forwarding the most trades to Opensea.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {Trade: {Dex: {ProtocolName: {in: "seaport_v1.4"}}}}
      limit: {count: 50}
      limitBy: {by: Transaction_To, count: 1}
      orderBy: {descendingByField: "count"}
    ) {
      Transaction {
        To
      }
      count
    }
  }
}

OpenSea API - Most traded NFTs on Opensea

We can aggregate trading vol, trade count, buyer, seller, and nfts and sort them based on trade count in the following query to get the most traded NFT on OpenSea.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {Trade: {
        Dex: {
          ProtocolName: {
            in: "seaport_v1.4"
            }
          }
        },
        Transaction: {
          To: {
            is: "0x00000000000000adc04c56bf30ac9d3c0aaf14dc"
            }
          }
        }
      orderBy: {descendingByField: "count"}
      limit: {count: 10}
    ) {
      tradeVol: sum(of: Trade_Buy_Amount)
      count
      buyers: count(distinct: Trade_Buy_Buyer)
      seller: count(distinct: Trade_Buy_Seller)
      nfts: count(distinct: Trade_Buy_Ids)
      Trade {
        Buy {
          Currency {
            Name
            ProtocolName
            Symbol
            Fungible
            SmartContract
          }
        }
      }
    }
  }
}

In terms of trade count Introducing World App is the most traded NFT with 94634 trades, then Gemesis with 87655 trades, and XTREME PIXELS with 56396 trades

Opensea API - Total buy sell of an NFT token on Opensea

To get the stats for specific NFT, we need to add the Nakamigos NFT contract address in the above query.

Top buyers of NFTs on Opensea

To know who are top buyers of NFTs, we can use thefollowing query.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {
        Trade: {
          Dex: {
            ProtocolName: {
              in: "seaport_v1.4"
            }
          },
          Buy: {
            Currency: {
              Fungible: false
            }
          }
        },
        Transaction: {
          To: {
            is: "0x00000000000000adc04c56bf30ac9d3c0aaf14dc"
          }
        }
      }
      orderBy: {descendingByField: "count"}
      limit: {count: 10}
    ) {
      count
      uniq_tx: count(distinct: Transaction_Hash)
      Block {
        first_date: Time(minimum: Block_Date)
        last_date: Time(maximum: Block_Date)
      }
      nfts: count(distinct: Trade_Buy_Ids)
      difffernt_nfts: count(distinct: Trade_Buy_Currency_SmartContract)
      total_money_paid: sum(of: Trade_Sell_Amount)
      Trade {
        Buy {
          Buyer
        }
      }
    }
  }
}

However, if you want to know the top buyers of a specific NFT, then you need to add the Currency’s smart contract address. For example,in this query, we are getting top buyers ofThe Orangez NFT token.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {
        Trade: {
          Dex: {
            ProtocolName: {
              in: "seaport_v1.4"
            }
          },
          Buy: {
            Currency: {
              Fungible: false,
              SmartContract: {
                is: "0xcd76d0cf64bf4a58d898905c5adad5e1e838e0d3"
              }
            }
          }
        },
        Transaction: {
          To: {
            is: "0x00000000000000adc04c56bf30ac9d3c0aaf14dc"
          }
        }
      }
      orderBy: {descendingByField: "count"}
      limit: {count: 10}
    ) {
      count
      uniq_tx: count(distinct: Transaction_Hash)
      Block {
        first_date: Time(minimum: Block_Date)
        last_date: Time(maximum: Block_Date)
      }
      nfts: count(distinct: Trade_Buy_Ids)
      difffernt_nfts: count(distinct: Trade_Buy_Currency_SmartContract)
      total_money_paid: sum(of: Trade_Sell_Amount)
      Trade {
        Buy {
          Buyer
        }
      }
    }
  }
}

OpenSea NFT API - Specific buyer stats for an NFT on Opensea

In this query, we will get specific buyer stats for a specific NFT on Opensea.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {
        Trade: {
          Dex: {
            ProtocolName: {
              in: "seaport_v1.4"
            }
          },
          Buy: {
            Currency: {
              SmartContract: {
                is: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
              }
            },
            Buyer: {
              is: "0x2f9ecaa66e12b6168996a6b80cda9bb142f80dd0"
            }
          }
        },
        Transaction: {
          To: {
            is: "0x00000000000000adc04c56bf30ac9d3c0aaf14dc"
          }
        }
      }
      orderBy: {descendingByField: "count"}
      limit: {count: 10}
    ) {
      count
      uniq_tx: count(distinct: Transaction_Hash)
      Block {
        first_date: Time(minimum: Block_Date)
        last_date: Time(maximum: Block_Date)
      }
      nfts: count(distinct: Trade_Buy_Ids)
      Trade {
        Buy {
          Buyer
          Currency {
            Name
            ProtocolName
            Symbol
            Fungible
            SmartContract
          }
        }
      }
    }
  }
}

For example, in the following query, we are getting the first and last transfer, total trade count, and NFTs bought for 0x2f9ecaa66e12b6168996a6b80cda9bb142f80dd0 address and BoredApeYachtClub NFT token.

OpenSea API - Latest NFT Trades on Seaport (Seaport API)

In the following query, we are getting allNFT trades for[Seaport](https://ide.bitquery.io/latest-NFT-trades-on-Ethereum-network)protocol (Here, seaport_v1.4 includes all seaport versions). Many marketplaces utilize the Seaport protocol; we can add a Smart contract in Trade → Dex → SmartContract to get a specific marketplace for this protocol.

{
  EVM {
    DEXTrades(
      limit: {offset: 0, count: 10}
      orderBy: {descendingByField: "Block_Time"}
      where: {
        Trade: {
          Dex: {
            ProtocolName: {
              is: "seaport_v1.4"
            }
          }
        }
      }
    ) {
      Trade {
        Dex {
          ProtocolName
        }
        Buy {
          Price
          Seller
          Buyer
          Currency {
            HasURI
            Name
            Fungible
            SmartContract
          }
        }
        Sell {
          Price
          Amount
          Currency {
            Name
          }
          Buyer
          Seller
        }
      }
      Transaction {
        Hash
      }
      Block {
        Time
      }
    }
  }
}

Opensea APIs - Get the Latest Trades of an Address

In this query, we are getting the latest NFT trades of this address. You can change the address according to your requirement. Additionally, if you want to see this address trade for a specific NFT, then add the smart contract of that NFT token in the filter; for example, check this query.

{
  EVM {
    DEXTrades(
      limit: {offset: 0, count: 10}
      orderBy: {descendingByField: "Block_Time"}
      where: {
        Trade: {
          Dex: {
            ProtocolName: {
              is: "seaport_v1.4"
            }
          },
          Sender: {
            is: "0x47f98fa3a3f8d8a62d99d112ce74e68b8de79f89"
          }
        }
      }
    ) {
      Trade {
        Dex {
          ProtocolName
        }
        Buy {
          Price
          Seller
          Buyer
          Currency {
            HasURI
            Name
            Fungible
            SmartContract
          }
        }
        Sell {
          Price
          Amount
          Currency {
            Name
          }
          Buyer
          Seller
        }
      }
      Transaction {
        Hash
      }
      Block {
        Time
      }
    }
  }
}

Get Top Traded Tokens

Let’s get the most traded NFTs on Ethereum of the month using the following query. If you see we are putting the date from 1st May to 28th May, you can change them accordingly.

{
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      orderBy: {descendingByField: "count"}
      limit: {offset: 0, count: 10}
      where: {
        Block: {
          Date: {
            since: "2023-05-01",
            till: "2023-05-28"
          }
        },
        Trade: {
          Buy: {
            Currency: {
              Fungible: false
            }
          },
          Sell: {
            Currency: {
              Fungible: true
            }
          }
        }
      }
    ) {
      Trade {
        Buy {
          Currency {
            Symbol
            SmartContract
          }
          min_price: Price(minimum: Trade_Buy_Price)
          max_rice: Price(maximum: Trade_Buy_Price)
        }
        Sell {
          Currency {
            Symbol
            SmartContract
          }
        }
      }
      buy_amount: sum(of: Trade_Buy_Amount)
      sell_amount: sum(of: Trade_Sell_Amount)
      count

    }
  }
}

Getting Basic properties and stats of an NFT token

If you want to get basic properties and stats such as token NFTs, holders, total transfers, and first and last transfers, you can useAPI below. In this Graphql API, we are getting the LO-Fi PEPE token’s stats.

{
  EVM(dataset: combined, network: eth) {
    BalanceUpdates(
      orderBy: {descendingByField: "transfers"}
      limit: {count: 1}
      where: {
        Currency: {
          SmartContract: {
            is: "0x0fcbd68251819928c8f6d182fc04be733fa94170"
          }
        }
      }
    ) {
      ChainId
      Currency {
        Symbol
        Name
        SmartContract
      }
      transfers: count(if: {BalanceUpdate: {Type: {is: transfer}}})
      ids: uniq(of: BalanceUpdate_Id, method: approximate)
      holders: uniq(of: BalanceUpdate_Address, method: approximate)
      Block {
        last: Time(maximum: Block_Time)
        first: Time(minimum: Block_Time)
      }
    }
  }
}

Popular Orangez 

In the following query, we are checking the most transferred Orangez; we called them popular Orangez.

{
  EVM(dataset: combined, network: eth) {
    Transfers(
      orderBy: {descendingByField: "count"}
      limit: {offset: 0, count: 10}
      where: {
        Transfer: {
          Currency: {
            SmartContract: {
              is: "0xcd76d0cf64bf4a58d898905c5adad5e1e838e0d3"
            }
          }
        }
      }
    ) {
      ChainId
      Transfer {
        Currency {
          Symbol
          SmartContract
        }
        Id
        URI
        last_receiver: Receiver(maximum: Block_Number)
      }
      count
      receivers: uniq(of: Transfer_Receiver, method: approximate)
    }
  }
}

Top Holders of NFT token

In the following API, we are getting the token holders of the WokePixels NFT token. You can get holders of any NFT just by changing the smart contract address in the query.

{
  EVM(dataset: combined, network: eth) {
    BalanceUpdates(
      orderBy: {descendingByField: "balance"}
      limit: {offset: 0, count: 10}
      where: {
        Currency: {
          SmartContract: {
            is: "0x0fcbd68251819928c8f6d182fc04be733fa94170"
          }
        }
      }
    ) {
      ChainId
      BalanceUpdate {
        Address
      }
      balance: sum(of: BalanceUpdate_Amount)
      ids: uniq(of: BalanceUpdate_Id, method: approximate)
    }
  }
}

Conclusion

To learn, read this article on NFT APIs. Additionally, Sign up on our GraphQL IDE to get the API key for free. We have recently launched Streaming API to provide live blockchain data.

Also Read

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 hello@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.