Cookbook
Sample operations for common tasks with the Marketplace API. Run each one with your key, or open it in the explorer to change it.
Your key stays in this browser. It goes only to marketplace.api.district.net, in the District-Client-Authorization header. Reach out to your Enterprise account manager to get your key.
Read the store
Read the name, the description and the home page of the store that your key belongs to.
query Store {
marketplace {
name
handle
description
url
memberCount
sellerCount
}
}Search products
Search the products of the store by text. To read the next page, send pageInfo.endCursor as after.
query SearchProducts($query: String!, $after: String) {
products(query: $query, first: 10, after: $after) {
totalCount {
value
relation
}
edges {
node {
id
title
slug
url
priceRange {
... on ProductPriceRange {
min {
amount
currencyCode
}
max {
amount
currencyCode
}
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}{
"query": "vintage"
}Find products in a price range
Find the products in stock between two prices, cheapest first. A Decimal is a string, such as "19.99".
query ProductsInPriceRange($from: Decimal, $to: Decimal) {
products(
first: 10
where: {price: {from: $from, to: $to}, availability: [IN_STOCK]}
sort: [{field: PRICE, direction: ASC}]
) {
edges {
node {
title
url
displayVariant {
title
price {
amount
currencyCode
}
quantityAvailable
}
}
}
}
}{
"from": "10.00",
"to": "50.00"
}Read a product and its variants
Read one product by its slug, with the price and the stock of each variant. Get a slug from a product search.
query Product($slug: Slug!) {
product(slug: $slug) {
title
description
url
seller {
username
displayName
}
variants(first: 20) {
edges {
node {
id
title
price {
amount
currencyCode
}
quantityAvailable
}
}
}
}
}{
"slug": "your-product-slug"
}List live and upcoming livestreams
List the livestreams that are live now or that have a schedule, soonest first.
query UpcomingLivestreams {
livestreams(
first: 10
where: {status: [LIVE, SCHEDULED]}
sort: {field: START_AT, direction: ASC}
) {
edges {
node {
id
title
status
startAt
url
streamer {
username
displayName
}
}
}
}
}Find livestream replays
List the livestreams that ended, newest first. replayUrl is null when no replay is available.
query LivestreamReplays {
livestreams(
first: 10
where: {status: [ENDED]}
sort: {field: START_AT, direction: DESC}
) {
edges {
node {
title
startAt
endedAt
replayUrl
viewCounts {
total
}
}
}
}
}Browse collections
List the store's curated collections in the seller's order, with the first products of each.
query Collections {
collections(first: 5) {
edges {
node {
displayName
slug
products(first: 3) {
edges {
node {
title
url
}
}
}
}
}
}
}