Skip to content

API Reference / Profit

Count the item names in the profit by item list

Returns the number of distinct item names ListPnLByItem would return for the same filter, so a page can show how many different items traded in the period.

POST/contracts.v1.Contracts/CountPnLByItem

Request body

application/jsonRequired

Request for the number of item names ListPnLByItem would return for the same filter.

filter?PnLByItemFilter

The same filter as ListPnLByItem, so the count matches the list.

Show attributes
activity?string

Optional filter: BOUGHT keeps only names with an item bought in the period, REALIZED only names with an item sold or lost in the period, so a contract's purchases by item or its profit by item each count only their own side.

Value in"PNL_BY_ITEM_ACTIVITY_BOUGHT""PNL_BY_ITEM_ACTIVITY_REALIZED"

contractId?string

Optional filter: the bought and held sides count only items this contract bought. The sold and lost side counts the items credited to it as their buying or selling contract, as GetPnLBreakdown and GetPnLPeriods credit them, so a contract's rows sum to its own figures.

Format"byte" base64

endTime?string

Optional end of the period, exclusive. Lifetime when absent.

Format"date-time"

marketHashNames?array<string>

Exact item names, OR within the field, so an item page reads its own row, or a page of catalog items reads theirs in one call. Empty includes every item. At most 200 names.

query?string

Optional case-insensitive substring of the item name.

sign?string

Optional filter on the sign of the row's realised profit: PROFIT keeps rows at or above zero, LOSS rows below zero.

Value in"PROFIT_SIGN_PROFIT""PROFIT_SIGN_LOSS"

startTime?string

Optional start of the period, inclusive. Sold items are windowed on sale completion time and bought items on delivery time. Lifetime when absent.

Format"date-time"

Response body

application/json

Success

count?integer

Number of distinct item names matching the filter.

Format"int32"

curl -X POST "https://api.goldmine.to/contracts.v1.Contracts/CountPnLByItem" \
  -H "Authorization: Bearer $CSTRADER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": {
      "activity": "PNL_BY_ITEM_ACTIVITY_BOUGHT",
      "contractId": "AY86PB0ufwCKGyw9Tl9gcQ==",
      "endTime": "2026-11-03T16:10:00Z",
      "marketHashNames": [
        "AK-47 | Redline (Field-Tested)"
      ],
      "query": "example",
      "sign": "PROFIT_SIGN_PROFIT",
      "startTime": "2026-11-03T16:10:00Z"
    }
  }'
{
  "count": 3
}