DEV Community

Divyasshree for Bitquery

Posted on

All Questions on OpenSea API Answered

How can I find on-chain data for NFT collections?

You can try any free blockchain data provider to get NFT collection information. Bitquery for example provides a free no-code explorer, you put in the collection address and get complete information on sales, transfers, and NFT images. E.g. Saints_of_LA (SAINTS) NFTs

SAINTS NFT

How can I fetch my assets data with Opensea API?

The Opensea API has a retrieve an asset endpoint https://docs.opensea.io/v1.0/reference/retrieving-a-single-asset However, the API key is not easy to get. A simpler method would be to use Bitquery Opensea API for free or the Bitquery no-code explorer to get detailed information on the asset. This GraphQL query for example gets top holders of the SAINTS NFT. Run it here

query MyQuery {
  EVM(dataset: archive, network: eth) {
    TokenHolders(
      date: "2023-10-16"
      tokenSmartContract: "0xdac17f958d2ee523a2206206994597c13d831ec7"
      limit: {count: 10}
      orderBy: {descending: Balance_Amount}
    ) {
      Balance {
        Amount
      }
      Holder {
        Address
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

How can I get all the NFT contract addresses via Opensea API?

You can use Bitquery's Opensea API to get all NFT contract addresses. Below GraphQL query gets top traded NFTs on BLUR. Run it here

query MyQuery {
  EVM(dataset: combined, network: eth) {
    DEXTrades(
      where: {Trade: {Dex: {ProtocolName: {in: "seaport_v1.4"}}}, Transaction: {To: {is: "0x39da41747a83aeE658334415666f3EF92DD0D541"}}}
      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
          }
        }
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

How can I obtain the most popular NFT being traded on a particular day?

You can get it with Bitquery NFT API. The query below gets the most traded NFT on Opensea. For getting trades on a different marketplace, set the contract address in Tofield. You can run the query here

query MyQuery {
  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
          }
        }
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Verify Opensea NFT ownership via API

Bitquery has an NFT Ownership API that gives you information on not only OpenSea but also Blur, X2Y2, and other marketplaces.

To check ownership for an NFT, type the NFT address into the explorer and get complete information. Click on "Get API" to see a detailed API.

Image description

Top comments (0)