Aggregated queries

Some aggregation plugins are available to count some data. You can use them in simple queries.

If you look at the indexer playground docs and schema on the right panel, you can see some aggregate fields. They allow us to make some mathematical calculations for some specific dataNFTs. Let's keep the example to query some NFT filtered by a specific owner and calculate the total amount in CAPS for each listed NFT.

query {
  nftEntities(
    filter: {
      owner: { equalTo: "5CDGXH8Q9DzD3TnATTG6qm6f4yR1kbECBGUmh2XbEBQ8Jfa5" }
    }
  ) {
    totalCount
    aggregates {
      sum {
        priceRounded
      }
    }
    nodes {
      nftId
      owner
      creator
      collectionId
      offchainData
      priceRounded
    }
  }
}

The expected outcome will be :

...
aggregates: {
        sum: {
          priceRounded: 39900
        }
      },
...

Last updated