API Reference / Contracts
Count contracts per facet value
Returns, for each requested facet field (type, account group, problem), how many contracts in the workspace match each of its values under the list's filter and status selection, with the field's own filter left out so the flyout shows the counts of the other choices. At most 8 fields per call and 50 values per field.
/ contracts. v1. Contracts/ GetContractFacetCountsRequest body
application/jsonRequired
Request for the per-value counts of up to 8 facet fields of the contracts list in the caller's workspace, under the list's filter and status selection.
fields?array<string>The facet fields to count, at most 8.
Value in"CONTRACT_"CONTRACT_"CONTRACT_
filter?ContractFilterThe same filter as ListContracts. Each facet is counted with every other field of it applied but not its own.
Show attributes
accountGroupIds?array<string>Only contracts assigned to one of these account groups, OR within the field. Empty does not restrict. A contract with no account group never matches a non-empty set.
createdBefore?stringOnly contracts created before this time. Absent sets no upper bound.
Format"date-time"
createdFrom?stringOnly contracts created at or after this time. Absent sets no lower bound.
Format"date-time"
evaluated?booleanTrue requires a recorded successful evaluation. False requires no recorded successful evaluation. Omitted includes both.
evaluatedBefore?stringOnly contracts last evaluated before this time. Contracts never evaluated do not match. Absent sets no upper bound.
Format"date-time"
evaluatedFrom?stringOnly contracts last evaluated at or after this time. Contracts never evaluated do not match. Absent sets no lower bound.
Format"date-time"
problems?array<string>Only contracts in at least one of these health conditions, OR within the field, by the same derivation that fills Contract.problems. Empty does not restrict.
Value in"CONTRACT_"CONTRACT_"CONTRACT_"CONTRACT_
profitFrom?stringStart of the window for the realised profit sort, not a condition on which contracts match. Unset counts every sale. Read only by a list sorted by realised profit, and bound to its cursor.
Format"date-time"
query?stringCase-insensitive literal substring, not a regular expression or wildcard pattern, matched against the contract name or against the market_hash_name of any item in the contract's current intents (the items its latest evaluation targets, which already resolve weapon, paint, category, collection and referenced filter sets). A draft has no intents, so it matches by name only. Absent or empty matches every contract.
snapshotMaximum?stringOnly contracts whose latest snapshot number is at most this. Absent sets no upper bound.
Format"int64"
snapshotMinimum?stringOnly contracts whose latest snapshot number is at least this. Absent sets no lower bound.
Format"int64"
types?array<string>Contract types to include, OR within the field. Empty includes every type.
Value in"CONTRACT_"CONTRACT_
updatedBefore?stringOnly contracts a user last edited before this time. Absent sets no upper bound.
Format"date-time"
updatedFrom?stringOnly contracts a user last edited at or after this time. Absent sets no lower bound.
Format"date-time"
statuses?array<string>The status selection of the open tab, applied to every facet. Empty includes every status.
Value in"CONTRACT_"CONTRACT_"CONTRACT_
Response body
application/json
Success
facets?array<ContractFacetCounts>The breakdown of each requested field, in request order.
Show attributes
counts?FacetFieldCountsThe top values by count, then value, at most 50, with truncated set when more values exist.
Show attributes
truncated?booleanTrue when the field has more than 50 values, so the list shows only the 50 most common.
values?array<FacetValueCount>The values and their counts, ordered by count descending then by value, at most 50.
Show attributes
count?stringNumber of rows carrying the value under the facet's predicate. Returned as a JSON string to preserve integer precision.
Format"int64"
value?stringThe value as the list rows carry it: an enum name, a base64 id or an account name, so a client maps it to a label exactly as it maps a row.
field?stringThe facet field these counts break down.
Value in"CONTRACT_"CONTRACT_"CONTRACT_
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/GetContractFacetCounts" \
-H "Authorization: Bearer $CSTRADER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"statuses": [
"CONTRACT_STATUS_ACTIVE"
],
"fields": [
"CONTRACT_FACET_FIELD_TYPE"
]
}'const res = await fetch("https://api.goldmine.to/contracts.v1.Contracts/GetContractFacetCounts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CSTRADER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"statuses": [
"CONTRACT_STATUS_ACTIVE"
],
"fields": [
"CONTRACT_FACET_FIELD_TYPE"
]
}),
});
const data = await res.json();body := strings.NewReader(`{
"statuses": [
"CONTRACT_STATUS_ACTIVE"
],
"fields": [
"CONTRACT_FACET_FIELD_TYPE"
]
}`)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://api.goldmine.to/contracts.v1.Contracts/GetContractFacetCounts", 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/GetContractFacetCounts",
headers={"Authorization": f"Bearer {os.environ['CSTRADER_API_KEY']}"},
json={
"statuses": [
"CONTRACT_STATUS_ACTIVE"
],
"fields": [
"CONTRACT_FACET_FIELD_TYPE"
]
},
)
data = res.json(){
"facets": [
{
"field": "CONTRACT_FACET_FIELD_TYPE",
"counts": {
"values": [
{
"value": "CONTRACT_TYPE_BUYING",
"count": "9"
},
{
"value": "CONTRACT_TYPE_SELLING",
"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."
}