All Questions on OpenSea API Answered
Tags: opensea, blockchain, nft, graphql
Published: 2023-10-17 12:17:41

## 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 ](https://explorer.bitquery.io/ethereum/token/0xbed2470ded2519c13eaaf3bd970015ef404d3d20/token_dex_trades)

![SAINTS NFT](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jqp5tz25qs5oiwh18pk.png)

## 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 ](https://explorer.bitquery.io/ethereum/token/0xbed2470ded2519c13eaaf3bd970015ef404d3d20/token_dex_trades)to get detailed information on the asset.  This GraphQL query for example gets top holders of the SAINTS NFT. [Run it here](https://ide.bitquery.io/Top-Holders-of-SAINTS-NFT)
```
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
      }
    }
  }
}
```

## 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](https://ide.bitquery.io/Most-traded-NFT-on-Blur-marketplace)
```
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
          }
        }
      }
    }
  }
}
```

## 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 `To `field. You can run the query [here](https://ide.bitquery.io/Top-Traded-NFTs-on-Opensea)

```
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
          }
        }
      }
    }
  }
}
```

## Verify Opensea NFT ownership via API
Bitquery has an [NFT Ownership API](https://docs.bitquery.io/docs/examples/nft/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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uuwox5whvdbvsrumawl7.png)