Top products
get_top_productsThe products that earned the most in the current period (ten unless limit asks for up to 50), largest net sales first, with netSales (after returns: the figure to quote as what it sold), revenueBeforeReturns, returns, units, cost (what those units cost), grossProfit, marginPct, and changePct against previousRevenue (revenue before returns). Each row also carries revenueShare — its fraction of the listed products' revenue — and rankedRevenue is their combined total, so a breakdown by product needs no arithmetic of your own. mostProfitable lists them by grossProfit and highestMargin by marginPct (with enough units to mean something), each already ranked: use those lists, in their order, instead of ranking the rows yourself. Use when asked which products sell best, which are growing or slowing, which are most profitable, or for a breakdown of revenue by product. A null cost, grossProfit or margin means costs are missing for that product, not that it earns nothing — never treat a null as zero and never fill one in by subtracting. If truncated is true some orders had more line items than Shopify returns at once, so the split is partial — say so. Optional from and to (inclusive YYYY-MM-DD, both or neither, never after today) read another span instead of the default period. A named month, a week or two dates the operator gave MUST be sent here: without them this reads the last 30 days, which is not that month.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Last day of the span, inclusive, as YYYY-MM-DD; not after today. Send together with `from`, or omit both to read the default 30-day period. | |
| from | No | First day of the span, inclusive, as YYYY-MM-DD. Send together with `to`, or omit both to read the default 30-day period. | |
| limit | No | How many products, 1 to 50; omit for 10. Ask for more when the product in question is not in the top ten. |