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.
/ contracts. v1. Contracts/ CountPnLByItemRequest body
application/jsonRequired
Request for the number of item names ListPnLByItem would return for the same filter.
filter?PnLByItemFilterThe same filter as ListPnLByItem, so the count matches the list.
Show attributes
activity?stringOptional 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_"PNL_
contractId?stringOptional 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?stringOptional 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?stringOptional case-insensitive substring of the item name.
sign?stringOptional filter on the sign of the row's realised profit: PROFIT keeps rows at or above zero, LOSS rows below zero.
Value in"PROFIT_"PROFIT_
startTime?stringOptional 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?integerNumber of distinct item names matching the filter.
Format"int32"
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/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"
}
}'const res = await fetch("https://api.goldmine.to/contracts.v1.Contracts/CountPnLByItem", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CSTRADER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"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"
}
}),
});
const data = await res.json();body := strings.NewReader(`{
"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"
}
}`)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://api.goldmine.to/contracts.v1.Contracts/CountPnLByItem", 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/CountPnLByItem",
headers={"Authorization": f"Bearer {os.environ['CSTRADER_API_KEY']}"},
json={
"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"
}
},
)
data = res.json(){
"count": 3
}{
"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."
}