Skip to content

API Reference / Profit

Get profit broken down by market and contract

Returns a workspace's profit split by selling marketplace and by contract. The market split is realised only. The contract split pairs each contract's realised profit with the buy cost of the items it still holds.

POST/contracts.v1.Contracts/GetPnLBreakdown

Request body

application/jsonRequired

Request for the caller's workspace profit split by marketplace and by contract, optionally for sales completed within a time range.

contractId?string

Optional filter: scope the breakdown to one contract. by_market then splits the sales credited to that contract as buyer or seller, and by_contract lists the counterpart contracts of those sales (the selling contracts of the items it bought, and the buying contracts of the items it sold) with their realised figures only.

Format"byte" base64

endTime?string

Optional end of the time range that filters the realised components on sale completion time. The unrealised half of by_contract ignores this range. The range also windows purchase_count on purchase time and items_bought on delivery time.

Format"date-time"

startTime?string

Optional start of the time range that filters the realised components (the whole by_market split and the realised half of by_contract) on sale completion time. The unrealised half of by_contract ignores this range.

Format"date-time"

Response body

application/json

Success

byContract?array<PnLByContract>

Realised and unrealised profit grouped by contract, one row per contract. With contract_id set, one row per counterpart contract of that contract's sales, carrying realised figures only.

Show attributes
contractId?string

The contract this row reports on.

Format"byte" base64

itemsBought?string

Number of items this contract bought that were delivered within the request's range, or lifetime without a range. Delivery time, never assignment time, so a purchase that has not delivered is not yet bought. Zero on a counterpart row of a contract-scoped breakdown.

Format"int64"

itemsInInventory?string

Number of items this contract bought and still holds.

Format"int64"

itemsSold?string

Number of sold items this contract participated in as buyer or seller.

Format"int64"

purchaseCount?string

Number of purchases this contract executed as the buying winner whose purchase time falls in the request's range, or lifetime without a range. A purchase that has not yet been executed carries no purchase time and is not counted. Zero on a counterpart row of a contract-scoped breakdown.

Format"int64"

realizedPnlCents?string

The whole realised profit of every sold item this contract participated in as buyer or seller, each such item counted once. Because an item's realised result is credited in full to both its buying and selling contract, these figures deliberately do not sum to the workspace total when the two differ.

Format"int64"

realizedPnlMicros?string

realized_pnl_cents in millionths of a dollar, from the exact buy cost. Exact to the millionth of a dollar, so a purchase charged a fraction of a cent counts at what it cost. The _cents figure beside it sums prices rounded up to a cent and is kept for limits.

Format"int64"

revenueCents?string

Sale proceeds of the items credited to this contract, in USD cents. Profit is exactly revenue minus sold cost.

Format"int64"

soldCostCents?string

What the items credited to this contract cost to buy, in USD cents.

Format"int64"

soldCostMicros?string

sold_cost_cents in millionths of a dollar, summed from the exact buy prices. Profit is exactly revenue_cents times 10,000 minus this. Exact to the millionth of a dollar, so a purchase charged a fraction of a cent counts at what it cost. The _cents figure beside it sums prices rounded up to a cent and is kept for limits.

Format"int64"

unrealizedCostCents?string

Buy cost basis of items this contract bought and still holds, in cents.

Format"int64"

unrealizedCostMicros?string

unrealized_cost_cents in millionths of a dollar, summed from the exact buy prices. Exact to the millionth of a dollar, so a purchase charged a fraction of a cent counts at what it cost. The _cents figure beside it sums prices rounded up to a cent and is kept for limits.

Format"int64"

byMarket?array<PnLByMarket>

Realised profit grouped by selling marketplace. With contract_id set, only the sales credited to that contract.

Show attributes
itemsSold?string

Number of sold items settled by this market.

Format"int64"

marketplace?string

The selling market that settled the sale. "unknown" when the sale predates selling_marketplace and cannot be attributed.

realizedPnlCents?string

Realised profit for the items this market settled, in cents: the sum of sell_price_cents minus buy_price_cents over those sold items.

Format"int64"

realizedPnlMicros?string

realized_pnl_cents in millionths of a dollar, from the exact buy cost. Exact to the millionth of a dollar, so a purchase charged a fraction of a cent counts at what it cost. The _cents figure beside it sums prices rounded up to a cent and is kept for limits.

Format"int64"

sellRevenueCents?string

Realised sell revenue settled by this market, in cents: the sum of sell_price_cents over the sold items it settled.

Format"int64"

curl -X POST "https://api.goldmine.to/contracts.v1.Contracts/GetPnLBreakdown" \
  -H "Authorization: Bearer $CSTRADER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "startTime": "2026-01-01T00:00:00Z",
    "endTime": "2026-06-30T23:59:59Z"
  }'
{
  "byMarket": [
    {
      "marketplace": "csfloat",
      "sellRevenueCents": "1320000",
      "realizedPnlCents": "205000",
      "itemsSold": "198"
    },
    {
      "marketplace": "unknown",
      "sellRevenueCents": "160000",
      "realizedPnlCents": "25000",
      "itemsSold": "19"
    }
  ],
  "byContract": [
    {
      "contractId": "EBESExQVFhcYGRobHB0eHw==",
      "realizedPnlCents": "150000",
      "unrealizedCostCents": "220000",
      "itemsSold": "120",
      "itemsInInventory": "40"
    },
    {
      "contractId": "ICEiIyQlJicoKSorLC0uLw==",
      "realizedPnlCents": "80000",
      "unrealizedCostCents": "200000",
      "itemsSold": "97",
      "itemsInInventory": "55"
    }
  ]
}