Skip to content

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.

POST/contracts.v1.Contracts/GetContractFacetCounts

Request 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_FACET_FIELD_TYPE""CONTRACT_FACET_FIELD_ACCOUNT_GROUP""CONTRACT_FACET_FIELD_PROBLEM"

filter?ContractFilter

The 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?string

Only contracts created before this time. Absent sets no upper bound.

Format"date-time"

createdFrom?string

Only contracts created at or after this time. Absent sets no lower bound.

Format"date-time"

evaluated?boolean

True requires a recorded successful evaluation. False requires no recorded successful evaluation. Omitted includes both.

evaluatedBefore?string

Only contracts last evaluated before this time. Contracts never evaluated do not match. Absent sets no upper bound.

Format"date-time"

evaluatedFrom?string

Only 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_PROBLEM_TARGETS_OUTDATED""CONTRACT_PROBLEM_HOLDINGS_UNCONFIRMED""CONTRACT_PROBLEM_EVALUATION_FAILED""CONTRACT_PROBLEM_UNPRICED_ITEMS"

profitFrom?string

Start 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?string

Case-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?string

Only contracts whose latest snapshot number is at most this. Absent sets no upper bound.

Format"int64"

snapshotMinimum?string

Only 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_TYPE_BUYING""CONTRACT_TYPE_SELLING"

updatedBefore?string

Only contracts a user last edited before this time. Absent sets no upper bound.

Format"date-time"

updatedFrom?string

Only 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_STATUS_DRAFT""CONTRACT_STATUS_BUILDING""CONTRACT_STATUS_ACTIVE"

Response body

application/json

Success

facets?array<ContractFacetCounts>

The breakdown of each requested field, in request order.

Show attributes
counts?FacetFieldCounts

The top values by count, then value, at most 50, with truncated set when more values exist.

Show attributes
truncated?boolean

True 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?string

Number of rows carrying the value under the facet's predicate. Returned as a JSON string to preserve integer precision.

Format"int64"

value?string

The 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?string

The facet field these counts break down.

Value in"CONTRACT_FACET_FIELD_TYPE""CONTRACT_FACET_FIELD_ACCOUNT_GROUP""CONTRACT_FACET_FIELD_PROBLEM"

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"
    ]
  }'
{
  "facets": [
    {
      "field": "CONTRACT_FACET_FIELD_TYPE",
      "counts": {
        "values": [
          {
            "value": "CONTRACT_TYPE_BUYING",
            "count": "9"
          },
          {
            "value": "CONTRACT_TYPE_SELLING",
            "count": "3"
          }
        ]
      }
    }
  ]
}