Collections
Here are some examples of common queries related to Collections using the NFT Data API.
Collection Info
query fetchCollectionInfo($slug: String) {
sui {
collections(
where: {
_or: [{ semantic_slug: { _eq: $slug } }, { slug: { _eq: $slug } }]
}
) {
id
title
slug
semantic_slug
description
floor
volume
usd_volume
cover_url
supply
verified
discord
twitter
website
}
}
}
💡
Note: This query highlights the use of the slug
and semantic_slug
parameters to fetch the collection info. The slug
is used as a unique identifier for collections, referring to the url slug and is derived from the collection's contract id. The semantic_slug
is a more human readable slug, and currently only present for more popular collections.
This query also demonstrates the use of the _or
operator to query collections based on either the slug
or semantic_slug
if the value being passed in could be either.
Collection Stats
query fetchCollectionStats($slug: String!) {
sui {
collection_stats(slug: $slug) {
total_mint_volume
total_mint_usd_volume
total_mints
total_sales
total_usd_volume
total_volume
day_volume
day_sales
day_usd_volume
}
}
}
Collection Items
query fetchCollectionItems(
$where: nfts_bool_exp!
$order_by: [nfts_order_by!]
$offset: Int
$limit: Int!
) {
sui {
nfts(where: $where, order_by: $order_by, offset: $offset, limit: $limit) {
id
token_id
name
media_url
media_type
ranking
owner
}
}
}
Collection Bids
query fetchCollectionBids($where: bids_bool_exp!, $order_by: [bids_order_by!]) {
sui {
bids(where: $where, order_by: $order_by) {
id
nonce
bidder
price
remaining_count
}
}
}
Collection Attributes
query fetchCollectionAttributes($collectionId: uuid!) {
sui {
collection_attributes(
where: { collection_id: { _eq: $collectionId } }
) {
id
type: trait_type
value
rarity
}
}
}
Collection Holders
query fetchCollectionHolders(
$slug: String!
$trending_by: HoldersBy!
$offset: Int = 0
$limit: Int!
) {
sui {
collection_holders(
slug: $slug
trending_by: $trending_by
offset: $offset
limit: $limit
) {
collection_id
current_holdings
owner
minted
sold
sold_volume
total_holding_time
total_holdings
}
}
}
Collection Search
query collectionSearch($text: String, $offset: Int, $limit: Int) {
sui {
collections_search(
args: { text: $text }
offset: $offset
limit: $limit
) {
id
supply
floor
slug
semantic_slug
title
usd_volume
volume
cover_url
verified
}
}
}
Collection Floor History
query fetchCollectionFloorHistory(
$slug: String!
$period: CollectionFloorPeriod!
$offset: Int!
$limit: Int!
) {
sui {
collection_floors(
slug: $slug
period: $period
offset: $offset
limit: $limit
) {
time
usd_value
value
}
}
}
Collection Activity
query fetchCollectionActivity(
$where: recent_actions_bool_exp
$offset: Int
$limit: Int!
) {
sui {
recent_actions(
where: $where
order_by: [{ block_time: desc }, { tx_index: desc }]
offset: $offset
limit: $limit
) {
id
type
price
usd_price
sender
receiver
tx_id
block_time
market_name
bought_on_tradeport
nft {
id
name
media_url
media_type
ranking
}
}
}
}
Top Trending Collections
query fetchTrendingCollections(
$period: TrendingPeriod!
$trending_by: TrendingBy!
$offset: Int = 0
$limit: Int!
) {
sui {
collections_trending(
period: $period
trending_by: $trending_by
offset: $offset
limit: $limit
) {
collection_id
current_trades_count
current_usd_volume
current_volume
previous_trades_count
previous_usd_volume
previous_volume
collection {
id
slug
semantic_slug
title
supply
cover_url
floor
usd_volume
volume
verified
}
}
}
}
Top Minting Collections
query fetchMintingCollections(
$period: MintingPeriod!
$trending_by: MintingBy!
$offset: Int = 0
$limit: Int!
) {
sui {
collections_minting(
period: $period
trending_by: $trending_by
offset: $offset
limit: $limit
) {
collection_id
current_mints_count
current_usd_volume
current_volume
previous_mints_count
previous_usd_volume
previous_volume
minting_start_time
collection {
id
slug
semantic_slug
title
supply
floor
verified
cover_url
}
}
}
}