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.
/ contracts. v1. Contracts/ GetPnLBreakdownRequest 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?stringOptional 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?stringOptional 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?stringOptional 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?stringThe contract this row reports on.
Format"byte" base64
itemsBought?stringNumber 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?stringNumber of items this contract bought and still holds.
Format"int64"
itemsSold?stringNumber of sold items this contract participated in as buyer or seller.
Format"int64"
purchaseCount?stringNumber 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?stringThe 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?stringrealized_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?stringSale proceeds of the items credited to this contract, in USD cents. Profit is exactly revenue minus sold cost.
Format"int64"
soldCostCents?stringWhat the items credited to this contract cost to buy, in USD cents.
Format"int64"
soldCostMicros?stringsold_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?stringBuy cost basis of items this contract bought and still holds, in cents.
Format"int64"
unrealizedCostMicros?stringunrealized_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?stringNumber of sold items settled by this market.
Format"int64"
marketplace?stringThe selling market that settled the sale. "unknown" when the sale predates selling_marketplace and cannot be attributed.
realizedPnlCents?stringRealised 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?stringrealized_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?stringRealised sell revenue settled by this market, in cents: the sum of sell_price_cents over the sold items it settled.
Format"int64"
application/json
The request was malformed, such as a missing required field or an unparseable cursor.
codestringThe Connect error code, such as "not_found".
details?array<object>Optional machine-readable error details.
messagestringA human-readable description of the error.
application/json
The request lacks a valid API key in the Authorization header.
codestringThe Connect error code, such as "not_found".
details?array<object>Optional machine-readable error details.
messagestringA human-readable description of the error.
application/json
The API key is not allowed to perform this action on this workspace.
codestringThe Connect error code, such as "not_found".
details?array<object>Optional machine-readable error details.
messagestringA human-readable description of the error.
application/json
The request was rate limited. Slow down and retry later.
codestringThe Connect error code, such as "not_found".
details?array<object>Optional machine-readable error details.
messagestringA human-readable description of the error.
application/json
An internal server error occurred.
codestringThe Connect error code, such as "not_found".
details?array<object>Optional machine-readable error details.
messagestringA human-readable description of the error.
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"
}'const res = await fetch("https://api.goldmine.to/contracts.v1.Contracts/GetPnLBreakdown", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CSTRADER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"startTime": "2026-01-01T00:00:00Z",
"endTime": "2026-06-30T23:59:59Z"
}),
});
const data = await res.json();body := strings.NewReader(`{
"startTime": "2026-01-01T00:00:00Z",
"endTime": "2026-06-30T23:59:59Z"
}`)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://api.goldmine.to/contracts.v1.Contracts/GetPnLBreakdown", body)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CSTRADER_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)import os, requests
res = requests.post(
"https://api.goldmine.to/contracts.v1.Contracts/GetPnLBreakdown",
headers={"Authorization": f"Bearer {os.environ['CSTRADER_API_KEY']}"},
json={
"startTime": "2026-01-01T00:00:00Z",
"endTime": "2026-06-30T23:59:59Z"
},
)
data = res.json(){
"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"
}
]
}{
"code": "invalid_argument",
"message": "The request was malformed, such as a missing required field or an unparseable cursor."
}{
"code": "unauthenticated",
"message": "The request lacks a valid API key in the Authorization header."
}{
"code": "permission_denied",
"message": "The API key is not allowed to perform this action on this workspace."
}{
"code": "resource_exhausted",
"message": "The request was rate limited. Slow down and retry later."
}{
"code": "internal",
"message": "An internal server error occurred."
}