# Get floor price of a collection

SHYFT’s SuperIndexer can also be used to create various <mark style="color:yellow;">utility functions</mark> which can readily be used in real-life dApps. One such example can be getting <mark style="color:yellow;">floor price</mark> of a particular NFT collection across 3 marketplaces. This also requires a little help from SHYFT’s DAS APIs. The steps are as follows,

* Firstly, we get all NFTs belonging to a collection using DAS <mark style="color:yellow;">getAssetByGroup</mark> method, which accepts the collection address and returns the list of NFTs
* This list can be used to filter the <mark style="color:yellow;">nftMint</mark>/<mark style="color:yellow;">tokenMint</mark> field of the marketplaces using graphQl, using the <mark style="color:yellow;">\_in</mark> check, which enables graphQl to check for a list of values. This can be fetched using a <mark style="color:yellow;">single cross-program</mark> query
* once we have the prices of all NFTs from all three marketplaces, we can easily find out the <mark style="color:yellow;">lowest price NFT from each marketplace</mark> belonging to that collection
* The <mark style="color:yellow;">lowest price</mark> NFT among 3 marketplaces is the <mark style="color:yellow;">floor price</mark> of the collection

#### Getting NFT mintlist for a collection using DAS

<pre class="language-typescript" data-overflow="wrap"><code class="lang-typescript">let page = 1;
let assets = [];

while (page > 0) {
<strong>  const assetsByGroup = await shyft.rpc.getAssetsByGroup({
</strong>    groupKey: 'collection',
    groupValue: collectionAdress,
    page,
    limit: 1000,
  }); //getting NFTs for a collection in a paginated manner

  assets.push(...assetsByGroup.items); //adding to an array
  page = assetsByGroup.total !== 1000 ? -1 : page + 1;
}
</code></pre>

{% hint style="info" %}
You can also use our [<mark style="color:red;">MintList</mark>](https://airdrop.shyft.to/) tool to get a collection's mint list.
{% endhint %}

#### Get all listings from marketplace using graphQl

{% code overflow="wrap" %}

```javascript

async function getAllBidsFromCollection(allNftMintsforCollection) {
    const query = gql`
    query MyQuery {
        MAGIC_EDEN_V2_SellerTradeStateV2(
          where: {tokenMint: {_in: ${JSON.stringify(allNftMintsforCollection)}}}
        ) {
          tokenMint
          pubkey
          seller
          buyerPrice
        }
        Tensor_SingleListing(
          where: {nftMint: {_in: ${JSON.stringify(allNftMintsforCollection)}}}
        ) {
          owner
          nftMint
          price
        }
        SNIPER_MARKET_SOLNFTOrderV1(
          where: {nftMint: {_in: ${JSON.stringify(allNftMintsforCollection)}}}
        ) {
          nftMint
          price
          owner
        }
      }
    `;

  const response = await graphQLClient.request(query);
  console.dir(response,{depth: null});
}
```

{% endcode %}

This step would give us all NFT listings across 3 marketplaces, along with their prices. In the next step we have to filter the listings to get NFTs with the lowest price.

{% hint style="info" %}
The GraphQL <mark style="color:yellow;">\_in</mark> filter can be used to check for keys in a range of values
{% endhint %}

#### Getting the lowest price NFTs and the floor price

```javascript
function findSmallestItem(items, property) {
  if (items.length === 0) {
    return undefined;
  }

  return items.reduce((smallest, item) => {
    return item[property] < smallest[property] ? item : smallest;
  }, items[0]);
}
```

This function can be used to retrieve the lowest priced NFT for each marketplace, and then the lowest price NFT among three is the floor price of the collection


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shyft.to/solana-indexers/case-studies/cross-marketplace-queries/get-floor-price-of-a-collection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
