Breakdown

A comprehensive list of the breakdown query keys, allowed fields values, and operators for the cart resource

To perform a breakdown query on the cart resource send a POST request to the /carts/breakdown endpoint specifying the query keys and filter parameters like in the generic example below:

{
  "breakdown": {
    "by": "...",
    "field": "...",
    "operator": "...",
    "condition": { ... },
    "sort": "...",
    "limit": ...,
    "breakdown": {
      "by": "...",
      "field": "...",
      "operator": "...",
      "condition": { ... },
      "sort": "...",
      "limit": ...
    }
  },
  "filter": { ... }
}

Please find more information on how breakdown queries work here.

Query keys

These are the keys you need to set when performing a breakdown query:

KeyTypeRequiredDescriptionValues

by

String

The field you want the results of the query aggragated by.

See the related table to check the full list of valid values for this key.

field

String

The field of the resource you want the metrics or statistics computed on.

See the related table to check the full list of valid values for this key.

operator

String

The computing operator.

See the related table to check the full list of valid operators based on the value you assigned to the field key.

condition

Object

An additional constraint to fine-tune the set of records shown in the response, applied to the computed results of the query. It is available for operators that return single numeric (float or integer) values.

One of: "eq": ...

"ne": ...

"gt": ...

"gte": ...

"lt": ...

"lte": ...

"gt_lt": [...]

"gte_lte": [...]

"gte_lt": [...]

"gt_lte": [...] (default is no condition).

sort

String

The way you want the results of the query to be sorted.

One of asc or desc (default is desc).

limit

Integer

The maximum number of records shown in the response.

Default is 10, max is 100.

breakdown

Object

The optional nested breakdown.

See the related table to check full list of valid values for the nested breakdown by key, based on the value you assigned to the parent breakdown by key.

Operators and field values

These are the valid values you can specify for the field key of the breakdown query and the related valid operators, based on that key:

ValueOperators

customer.id

cardinality

value_count

customer.email

cardinality

value_count

customer.group_name

cardinality

value_count

line_items.code

cardinality

value_count

line_items.discount

avg

max

min

sum

stats

line_items.id

cardinality

value_count

line_items.item_id

cardinality

value_count

line_items.options_amount

avg

max

min

sum

stats

line_items.quantity

avg

max

min

sum

stats

line_items.tax_amount

avg

max

min

sum

stats

line_items.tax_rate

avg

max

min

sum

stats

line_items.total_amount

avg

max

min

sum

stats

line_items.unit_amount

avg

max

min

sum

stats

line_items.options.id

cardinality

value_count

line_items.options.quantity

avg

max

min

sum

stats

line_items.options.total_amount

avg

max

min

sum

stats

line_items.options.unit_amount

avg

max

min

sum

stats

market.id

cardinality

market.number

cardinality

value_count

order.adjustment_amount

avg

max

min

sum

stats

order.adjustment_tax_amount

avg

max

min

sum

stats

order.adjustment_taxable_amount

avg

max

min

sum

stats

order.discount_amount

avg

max

min

sum

stats

order.duty_amount

avg

max

min

sum

stats

order.gift_card_code

value_count

order.gift_card_amount

avg

max

min

sum

stats

order.id

cardinality

value_count

order.line_item_options_count

avg

max

min

sum

stats

order.number

value_count

order.payment_method_amount

avg

max

min

sum

stats

order.payment_method_tax_amount

avg

max

min

sum

stats

order.payment_method_taxable_amount

avg

max

min

sum

stats

order.reference

cardinality

value_count

order.reference_origin

cardinality

value_count

order.shipments_count

avg

max

min

sum

stats

order.shipping_amount

avg

max

min

sum

stats

order.shipping_taxable_amount

avg

max

min

sum

stats

order.skus_count

avg

max

min

sum

stats

order.subtotal_amount

avg

max

min

sum

stats

order.subtotal_tax_amount

avg

max

min

sum

stats

order.subtotal_taxable_amount

avg

max

min

sum

stats

order.total_amount

avg

max

min

sum

stats

order.total_amount_with_taxes

avg

max

min

sum

stats

order.total_tax_amount

avg

max

min

sum

stats

order.total_taxable_amount

avg

max

min

sum

stats

Nestable breakdowns and by values

These are the valid values you can specify for the by key of the breakdown query and the related forbidden values for the by key of the nested breakdown, based on the by key of the parent breakdown (i.e. for each row of the table below the full list of the valid values for the by key of the nested breakdown is given by all the values in the "Value" column except the values in the row's "Forbidden nesting" cell):

ValueForbidden nesting

billing_address.business

billing_address.geocoded

billing_address.localized

customer.*

shipping_address.*

line_items.item_type

order.freight_taxable

order.fulfillment_status

order.payment_status

order.status

billing_address.city

billing_address.country_code

billing_address.state_code

customer.*

shipping_address.*

line_items.item_type

billing_address.country_code

customer.*

shipping_address.*

line_items.item_type

billing_address.geocoded

billing_address.*

customer.*

shipping_address.*

line_items.item_type

billing_address.localized

billing_address.*

customer.*

shipping_address.*

line_items.item_type

billing_address.state_code

billing_address.country_code

customer.*

shipping_address.*

line_items.item_type

billing_address.zip_code

billing_address.country_code

billing_address.city

billing_address.geocoded

billing_address.localized

customer.*

shipping_address.*

line_items.item_type

customer.id

customer.email

customer.group_name

line_items.code

line_items.id

line_items.item_id

line_items.item_type

line_items.name

line_items.options.id

line_items.*

line_items.options.name

line_items.*

market.id

billing_address.geocoded

billing_address.localized

shipping_address.geocoded

shipping_address.localized

line_items.item_type

market.name

market.number

order.country_code

order.coupon_code

order.currency_code

order.freight_taxable

order.gift_card_code

order.guest

order.language_code

order.reference

order.reference_origin

order.status

order.tax_included

payment_method.source_type

payment_method.name

payment_method.moto

shipping_address.business

shipping_address.geocoded

shipping_address.localized

customer.*

billing_address.*

line_items.item_type

order.freight_taxable

order.fulfillment_status

order.payment_status

order.status

shipping_address.city

shipping_address.country_code

shipping_address.state_code

customer.*

billing_address.*

line_items.item_type

shipping_address.country_code

customer.*

billing_address.*

line_items.item_type

shipping_address.geocoded

billing_address.*

customer.*

shipping_address.*

line_items.item_type

shipping_address.localized

billing_address.*

customer.*

shipping_address.*

line_items.item_type

shipping_address.state_code

shipping_address.country_code

customer.*

billing_address.*

line_items.item_type

shipping_address.zip_code

shipping_address.country_code

shipping_address.city

shipping_address.geocoded

shipping_address.localized

customer.*

billing_address.*

line_items.item_type

tags.id

tags.name

Remember also that you cannot group the nested breakdown by the same field by which you're already grouping the parent breakdown.

Last updated