query
Structured analytics query on a catalog dataset. Metrics and dimensions are ids from describe(kind='datasets'); the server writes the SQL (curated path; SEPARATE from run_query's raw SQL). Metrics are additive (summed) or ratio (ratio-of-sums after aggregation, not an average of ratios). Dimensions: attributes label at the existing grain; segments fan rows. filters select dimensions before aggregation; having selects metrics after aggregation. Seller datasets (domain 'seller') use target amazon_sp; Ads datasets (domain 'ads', e.g. ads_performance) use target amazon_ads; eBay datasets (domain 'ebay') use target ebay — all validated against your account. A rejected request returns the legal vocabulary.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sort | No | Order-by list: [{field, dir: 'asc'|'desc'}]. field must be a selected metric or dimension. | |
| limit | No | Max rows (default 100). Clamped to the caller tier's max. | |
| round | No | Decimals, default 2. | |
| format | No | Default compact {columns,rows}; tsv smallest. | |
| having | No | Post-aggregation filter on metrics (incl. ratios). Same shape as `filters`. | |
| offset | No | Row offset for pagination (default 0). | |
| target | No | From get_session_context targets: kind:account[:unit]. | |
| compare | No | Period-over-period. Either the string 'previous_period' (same-length window immediately before time_range) or an explicit {start, end} (ISO dates). Adds <metric>_prev and <metric>_delta columns. Requires total granularity. | |
| dataset | Yes | Dataset id from describe(kind='datasets') (e.g. 'sales_traffic'). | |
| filters | No | Pre-aggregation filter on dimensions. A condition {field, op, value} or a boolean tree {and|or|not:[...]}, or a list (implicit AND). Metrics belong in `having`. | |
| metrics | No | Metric ids from describe(kind='datasets') (additive or ratio). | |
| dimensions | No | Attribute and/or segment ids to SELECT + GROUP BY. Each segment fans rows. | |
| time_range | Yes | Required date window {start, end} (ISO YYYY-MM-DD), clamped to your account's live available data. | |
| granularity | No | Time bucket (default 'total' = one row per dimension over the whole window). 'daily'/'weekly'/'monthly' add a time column = the granule start (weekly = Monday). Must be one of the dataset's time.granularities. | |
| marketplace_id | No | Amazon marketplace id (e.g. 'ATVPDKIKX0DER') — required for seller datasets (MCP: in target) and search_term_results. eBay: optional (e.g. 'EBAY_US'), omit for all. |