Skip to Content
MarketplaceAPI Reference

API Reference

This page documents all marketplace-related API endpoints. All endpoints follow our oRPC contract-first pattern — contracts are defined in @repo/api-dtos and handlers are implemented in @repo/api.

For details on how each feature works, see the relevant documentation pages. This is a quick reference for developers integrating with the API.

Cart Endpoints

The cart is where buyers collect items before checkout. Each user has one cart.

cart.get

Get the current user’s cart with all items.

FieldValue
AuthRequired
OutputCart with items, totals, and seller info

listings.search

Query the listings index (OpenSearch) with product and listing filters. Returns paginated products for sale with embedded listing info (min price per currency, listing count). Use this for searching what’s actually for sale; the marketplace router is reserved for other marketplace features (sales, purchases, orders, etc.).

FieldValue
AuthNot required (public)
Output{ pagination, products } — products include listing: { minPrice, listingCount }

Input:

  • product (optional): Product-level filters.
    • gameSlug, expansionSlug, nameSlug: Identity (exact match on slugs).
    • category: Exact match on product category.
    • type: Product type filter (e.g. card, sealed). In the API this is product.type; the index field is product.productType.
    • market: Price and change filters (priceUs, priceEu, change24hUs, change24hEu, change7dUs, change7dEu, change30dUs, change30dEu).
    • attributes: Game-specific filters (e.g. rarity, color). Game is inferred from product.gameSlug when building the query.
  • listing (optional): Listing-level filters: priceRange, condition, language, shipsTo, currency, graded, gradingService, quantity, sellerId, sellerUsername.
  • limit: Page size (required).
  • offset (optional): Pagination offset.
  • sort (optional): Array of [field, "asc" \| "desc"] (e.g. [["product.minPriceUs", "asc"]]).

Checkout Endpoints

Checkout creates a Stripe payment session from the cart.

checkout.create

Create a Stripe Checkout Session from the current cart.

FieldValue
AuthRequired
Output{ sessionUrl, transactionId }

Possible Errors:

  • CART_EMPTY — No items in cart
  • ITEMS_UNAVAILABLE — Some items no longer available
  • SHIPPING_UNAVAILABLE — Seller doesn’t ship to buyer’s country

Order Endpoints

Orders are created after checkout succeeds. Buyers and sellers have different views and actions.

Viewing Orders

EndpointWho uses itDescription
order.getOrderBuyer or SellerGet a single order by ID
order.getPurchasesBuyerList orders where you’re the buyer
order.getSalesSellerList orders where you’re the seller

All list endpoints support:

  • status (string[]) — Filter by order status
  • cursor (string) — For pagination
  • limit (number) — Page size (default 20)

Seller Actions

order.markShipped

Mark an order as shipped with tracking info.

ParameterTypeRequiredDescription
orderIdstringYesOrder to update
trackingNumberstringYesCarrier tracking number
carrierstringNoShipping carrier name

Requires: Seller role, order in pending_shipment

Buyer Actions

order.requestCancellation

Request cancellation of an order.

ParameterTypeRequiredDescription
orderIdstringYesOrder to cancel
reasonstringNoWhy you’re cancelling

Requires: Buyer role, within 7 days of order

This starts the 48-hour window. The seller can still ship to void the cancellation.

Dispute Endpoints

Disputes handle problems with orders. See Disputes & Refunds for the full flow.

Opening & Managing Disputes

order.openDispute

Open a dispute on an order.

ParameterTypeRequiredDescription
orderIdstringYesOrder to dispute
issueCategoriesstring[]YesWhat’s wrong (see categories below)
issueDescriptionstringYesDetailed explanation
evidenceUrlsstring[]NoPhotos or other proof
preferredOutcomestringNoWhat you’d like to happen

Issue Categories: missing_item, wrong_condition, counterfeit_resealed, wrong_product, damaged, not_received, other

Requires: Buyer role, order is shipped or delivered, within 30 days

Rating Endpoints

Reviews are submitted after orders complete. See Ratings & Reviews for the simultaneous reveal system.

rating.getOrderReview

Get review window status for an order.

ParameterTypeRequiredDescription
orderIdstringYesOrder to check

Returns deadline, whether each party has submitted, and revealed reviews (if any).

Seller Endpoints

Seller onboarding and configuration. See Seller Onboarding for the full flow.

seller.initiateOnboarding

Start the seller onboarding process.

ParameterTypeRequiredDescription
sellerTypestringYesindividual or pro
countrystringYesISO 3166-1 alpha-2 code

Returns a URL to the Stripe Connect onboarding flow.

Country cannot be changed after onboarding.

Error Handling

All endpoints use typed errors from the contract. In the frontend, you can handle them type-safely:

const [error, data] = await safe(mutation.mutateAsync(input)) if (isDefinedError(error)) { switch (error.code) { case 'ORDER_NOT_FOUND': console.log('Missing order:', error.data.orderId) // Typed! break case 'ITEM_NOT_AVAILABLE': showToast('This item is no longer available') break // ... handle other errors } }

Each error includes typed data with relevant context. Check the contract definitions for the exact shape of each error’s data.

Admin Order Endpoints

These endpoints are used by the internal admin dashboard (marketplace-admin). They require admin authentication.

adminOrders.listOrders

List and filter orders for the admin dashboard.

ParameterTypeRequiredDescription
pagenumberNoPage number (default: 1)
limitnumberNoPage size (default: 50, max: 100)
statusstring[]NoFilter by order statuses
searchstringNoSearch by order number or username
regionstringNo"NA" or "EU"
hasDisputebooleanNoFilter orders with disputes
isEscalatedbooleanNoFilter escalated disputes
shippingStatusstringNoFilter by tracking status
fundOperationStatusstringNoFilter by fund operation state
dateFrom / dateTostringNoDate range filter (ISO datetime)
sortBystringNo"createdAt", "updatedAt", "orderNumber", or "subtotal"
sortOrderstringNo"asc" or "desc"

Returns { orders, total, page, totalPages }.

Code Locations

Contracts (@repo/api-dtos)

DomainLocation
Cartpackages/core/api-dtos/src/lib/marketplace/cart/
Checkoutpackages/core/api-dtos/src/lib/marketplace/checkout/
Orderpackages/core/api-dtos/src/lib/marketplace/order/
Ratingpackages/core/api-dtos/src/lib/marketplace/rating/
Sellerpackages/core/api-dtos/src/lib/marketplace/seller/
Searchpackages/core/api-dtos/src/lib/marketplace/search-products.ts
Admin Orderspackages/backend/marketplace-admin/src/contracts/orders/

Handlers (@repo/api)

DomainLocation
Cartpackages/backend/api/src/lib/orpc/handlers/marketplace/cart/
Checkoutpackages/backend/api/src/lib/orpc/handlers/marketplace/checkout/
Orderpackages/backend/api/src/lib/orpc/handlers/marketplace/order/
Ratingpackages/backend/api/src/lib/orpc/handlers/marketplace/rating/
Sellerpackages/backend/api/src/lib/orpc/handlers/marketplace/seller/
Searchpackages/backend/api/src/lib/orpc/handlers/marketplace/search-products.handler.ts
Admin Orderspackages/backend/api/src/lib/orpc/handlers/marketplace-admin/orders/
Last updated on