Advanced Market Queries
When developers build their own marketplace on top of the Living Assets platform, whether within a video game, a web browser, or a mobile app, they often use the trading API to build their own custom databases, optimising the specific functionalities that they need.
The
allMarketAssetData
query provides an off-the-shelf entry point to some of the most common operations to all marketplaces, including pagination and filters, to help developers bootstrap a custom marketplace until they integrate their own specific needs. GraphQL
allMarketAssetData(
first: Int
last: Int
offset: Int
before: Cursor
after: Cursor
orderBy: [MarketAssetDataOrderBy!] = [NATURAL]
condition: MarketAssetDatumCondition
filter: MarketAssetDatumFilter
): MarketAssetDataConnection
This query returns a paginated list of asset data (more examples below). The parameters
first
, last
, offset
, before
, and after
are used for pagination. The orderBy
parameter is used to specify the ordering of the results, and the condition
and filter
parameters are used to filter the results.Relevant query inputs are the
MarketAssetDatumCondition
and MarketAssetDatumFilter
which allow filtering the received data.GraphQL
input MarketAssetDatumCondition {
assetId: String
buynowId: String
props: JSON
metadata: JSON
assetCreatedAt: Datetime
price: String
currencyId: Int
buynowCreatedAt: Datetime
buynowUpdatedAt: Datetime
validUntil: BigInt
symbol: String
isForSale: Boolean
universeId: Int
collectionId: Int
lastSaleUpdatedAt: Datetime
assetPropsFilter: AssetPropsFilterInput
marketMetaDataFilter: MarketMetadataFilterInput
}
The
MarketAssetDatumCondition
input is used to specify the condition to be used in determining which MarketAssetDatum
objects should be returned by the query. All fields are tested for equality and combined via the logical operatorAND.
It also contains the assetPropsFilter
and marketMetaDataFilter
inputs for filtering assets based on the contents of the props
and metadata
fields.GraphQL
input AssetPropsFilterInput {
key: String!
exactValue: String
containedValue: String
}
The
AssetPropsFilterInput
input is used to filter assets based on the contents of the props
field. The key
field specifies which key to filter on, and the exactValue
and containedValue
fields specify exact and partial matches, respectively.The filter will only apply to the properties at the root level of the props JSON object.
GraphQL
input MarketMetadataFilterInput {
key: String!
exactValue: String
containedValue: String
}
The
MarketMetadataFilterInput
input is used to filter assets based on the contents of the metadata field. The key
field specifies which key to filter on, and the exactValue
and containedValue fields specify exact and partial matches, respectively.GraphQL
input MarketAssetDatumFilter {
assetId: StringFilter
buynowId: StringFilter
assetCreatedAt: DatetimeFilter
price: StringFilter
currencyId: IntFilter
buynowCreatedAt: DatetimeFilter
buynowUpdatedAt: DatetimeFilter
validUntil: BigIntFilter
symbol: StringFilter
isForSale: BooleanFilter
universeId: IntFilter
collectionId: IntFilter
lastSaleUpdatedAt: DatetimeFilter
and: [MarketAssetDatumFilter!]
or: [MarketAssetDatumFilter!]
not: MarketAssetDatumFilter
}
The
MarketAssetDatumFilter
input is used to filter MarketAssetDatum
objects based on their fields. All fields are combined via the logical operator AND
. It also contains the AND
, OR
, and NOT
inputs for combining and negating filter expressions.Available filters are:
equalTo
, in
, lessThan
, isNull
and greaterThan
.GraphQL
type MarketAssetDataConnection {
nodes: [MarketAssetDatum]!
edges: [MarketAssetDataEdge!]!
pageInfo: PageInfo!
totalCount: Int!
}
The
MarketAssetDataConnection
type represents a connection to a list of MarketAssetDatum
objects. The nodes field is a list of the actual MarketAssetDatum
objects, the edges field contains the MarketAssetDatum
objects and cursors for pagination, the pageInfo
field provides information about the current page, and the totalCount
field provides the total number of MarketAssetDatum
objects that match the query.The relevant response field is
MarketAssetDatum,
which contains the returned information about the assets and their trades.GraphQL
type MarketAssetDatum {
assetId: String
buynowId: String
props: JSON
metadata: JSON
assetCreatedAt: Datetime
price: String
currencyId: Int
buynowCreatedAt: Datetime
buynowUpdatedAt: Datetime
validUntil: BigInt
symbol: String
isForSale: Boolean
universeId: Int
collectionId: Int
lastSaleUpdatedAt: Datetime
}
Please find below some examples of
allMarketAssetData
GraphQL queries:query {
allMarketAssetData(
filter: {
and: [
{ assetCreatedAt: { greaterThan: "2022-01-01T00:00:00Z" } },
{ buynowUpdatedAt: { greaterThan: "2022-02-01T00:00:00Z" } }
]
}
) {
nodes {
assetId
assetCreatedAt
buynowUpdatedAt
}
}
}
This query will return all assets created after January 1st, 2022, and updated after February 1st, 2022.
query {
allMarketAssetData(
filter: {
lastSaleUpdatedAt: { isNull: false }
}
orderBy: [LAST_SALE_UPDATED_AT_DESC]
first: 10
) {
nodes {
assetId
lastSaleUpdatedAt
}
}
}
This query will return the 10 most recently sold assets, sorted by the date they were last sold. It filters by the lastSaleUpdatedAt field to only include assets that have been sold at least once.
Last modified 4mo ago