Today, we'll explore Opensea NFT APIs and show you how to retrieve Opensea trading data using Bitquery Streaming APIs. Opensea has transitioned to the Seaport protocol, and we'll delve into its characteristics later in the article. For now, we'll use straightforward DEXTrades APIs to access NFT trades from Opensea.
Note: In the queries, you'll see seaport_v1.4
, which represents not just version 1.4 of Seaport but encompasses all Seaport versions.
This tutorial was originally published on Bitquery Blog. Please check out original post: Opensea NFT API - A Complete Developer Guide
- Getting Started
- Newly Created NFTs on Ethereum
- OpenSea Shared Storefront NFTs
- Latest NFT Trades on OpenSea
- Most traded NFTs on Opensea
- Total buy sell of an NFT token on Opensea
- Top buyers of NFTs on Opensea
- Specific buyer stats for an NFT on Opensea
- Latest NFT Trades on Seaport
- Get the Latest Trades of an Address
- Get Top Traded Tokens
- Getting Basic properties and stats of an NFT token
- Popular Orangez
- Top Holders of NFT token
- Conclusion
- About Bitquery
To get started for free, please create an account with your email: GraphQL IDE .Once you create the account, check out our docs to learn how to create your first query.
To learn more about how to use the Bitquery API, please see the following resources:
- Historical / Near-Realtime Chain Data: Blockchain API Documentation (V1 Graphql Docs) | Blockchain Graphql API (V1 API Docs)
- Realtime Data , Websocket and Cloud Product: Blockchain Streaming API (V2 Graphql Docs) | Streaming API (V2 API Docs)
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
}
}
}
}
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
}
}
}
}
}
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
}
}
}
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
To get the stats for specific NFT, we need to add the Nakamigos NFT contract address in the above query.
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
}
}
}
}
}
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.
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
}
}
}
}
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
}
}
}
}
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
}
}
}
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)
}
}
}
}
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)
}
}
}
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)
}
}
}
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
Bitquery is your comprehensive toolkit designed with developers in mind, simplifying blockchain data access. Our products offer practical advantages and flexibility.
-
APIs - Explore API: Easily retrieve precise real-time and historical data for over 40 blockchains using GraphQL. Seamlessly integrate blockchain data into your applications, making data-driven decisions effortless.
-
Coinpath® - Try Coinpath: Streamline compliance and crypto investigations by tracing money movements across 40+ blockchains. Gain insights for efficient decision-making.
-
Data in Cloud - Try Demo Bucket: Access indexed blockchain data cost-effectively and at scale for your data pipeline. We currently support Ethereum, BSC, Solana, with more blockchains on the horizon, simplifying your data access.
-
Explorer - Try Explorer: Discover an intuitive platform for exploring data from 40+ blockchains. Visualize data, generate queries, and integrate effortlessly into your applications.
Bitquery empowers developers with straightforward blockchain data tools. If you have questions or need assistance, connect with us on our Telegram channel or via email at hello@bitquery.io. Stay updated on the latest in cryptocurrency by subscribing to our newsletter below.
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.