{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tradedashboard-eu/json-schema/tradedashboard-eu-dashboard-query-schema.json",
  "title": "DashboardQuery",
  "description": "Shared request body for every analytical endpoint.\n\nOne customs-code selection (the ``customs_code`` shorthand or an explicit\n``baskets`` list -- exactly one of the two), one reporter (or group of\nreporters), a partner set, a period window and a frequency fully describe\na slice of Eurostat Comext/PRODCOM data. Individual endpoints read extra,\nendpoint-specific options from the query string (e.g. ``entity_level``,\n``flow``, ``partner``) rather than from this body.",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tradedashboard-eu-openapi.json#/components/schemas/DashboardQuery",
  "properties": {
    "reporter": {
      "type": "string",
      "maxLength": 120,
      "title": "Reporter",
      "description": "Declaring entity: an EU Member State, an EU candidate country, Northern Ireland ('XI'), or one of the three aggregate presets ('European Union', 'Euro area', 'EU candidate countries'), or a predefined reporter group name.",
      "default": "European Union"
    },
    "group_reporters": {
      "anyOf": [
        {
          "items": {
            "type": "string",
            "maxLength": 120
          },
          "type": "array",
          "maxItems": 300
        },
        {
          "type": "null"
        }
      ],
      "title": "Group Reporters",
      "description": "Explicit reporters for a custom reporter group. Each entry must be an EU Member State, EU candidate country, or Northern Ireland. When more than one is supplied the frame is aggregated into a synthetic group named after 'reporter'."
    },
    "partner_set": {
      "type": "string",
      "maxLength": 120,
      "title": "Partner Set",
      "description": "Named partner preset, e.g. 'non-EU countries', 'EU countries', 'all countries', or a predefined partner group.",
      "default": "non-EU countries"
    },
    "partners": {
      "anyOf": [
        {
          "items": {
            "type": "string",
            "maxLength": 120
          },
          "type": "array",
          "maxItems": 300
        },
        {
          "type": "null"
        }
      ],
      "title": "Partners",
      "description": "Explicit partner-country list that overrides 'partner_set' when present."
    },
    "period_start": {
      "type": "string",
      "pattern": "\\d{4}-\\d{2}",
      "title": "Period Start",
      "description": "Inclusive start of the analysis window, ISO month 'YYYY-MM'.",
      "default": {
        "year": 2015,
        "month": 1
      }
    },
    "frequency": {
      "$ref": "#/$defs/Frequency",
      "description": "Resampling frequency for the series: 'month', 'quarter' or 'year'.",
      "default": "quarter"
    },
    "remove_outliers": {
      "type": "boolean",
      "title": "Remove Outliers",
      "description": "Drop extreme unit-price outliers before computing weighted-average prices.",
      "default": true
    },
    "customs_code": {
      "anyOf": [
        {
          "type": "string",
          "description": "A canonical customs code, TOTAL, or a supported residual spelling."
        },
        {
          "items": {
            "type": "string",
            "description": "A canonical customs code, TOTAL, or a supported residual spelling."
          },
          "type": "array",
          "maxItems": 50
        },
        {
          "type": "null"
        }
      ],
      "title": "Customs Code",
      "description": "Combined Nomenclature customs code(s), 2–8 digits, or the literal 'TOTAL' meta-aggregate (all products combined). Residual customs codes are requestable too (e.g. 850440XX, 85SSS999, 85SSS); see https://tradedashboard.eu/faq-en.html#customscode for details. Pass a list to compare codes side by side, or to aggregate them in views that fold several codes into one basket: their volumes are summed and prices volume-weighted across every tab — except the Cross-section views, which keep each code separate. Exactly one of 'customs_code' and 'baskets' must be given."
    },
    "baskets": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Basket"
          },
          "type": "array",
          "maxItems": 50,
          "minItems": 1
        },
        {
          "type": "null"
        }
      ],
      "title": "Baskets",
      "description": "The explicit basket form of the customs-code selection: a list of baskets, each a list of (customs_code, optional month window) pieces summed into one displayed line. Use it to clip a code to specific months or to chain successor codes (e.g. [{pieces: [{customs_code: '8524', to_month: '2006-12'}, {customs_code: '85241100', from_month: '2007-01'}]}] with a period starting before 2007). Every piece must meet the requested period. Exactly one of 'customs_code' and 'baskets' must be given."
    },
    "period_end": {
      "type": "string",
      "pattern": "\\d{4}-\\d{2}",
      "title": "Period End",
      "description": "Inclusive end of the analysis window, ISO month 'YYYY-MM'. Defaults to roughly three months ago — the latest period Eurostat typically has fully reported."
    },
    "n_top": {
      "type": "integer",
      "maximum": 100.0,
      "minimum": 1.0,
      "title": "N Top",
      "description": "Number of top entities (by volume/value) to break out individually in charts.",
      "default": 7
    },
    "include_other": {
      "type": "boolean",
      "title": "Include Other",
      "description": "Bundle entities outside the top-N into a single 'Other' bucket.",
      "default": true
    },
    "include_residuals": {
      "type": "boolean",
      "title": "Include Residuals",
      "description": "Include the residual customs-code layer: residual rows in the breakdown views (subcode-compare, concentration-compare, volatility heatmap), the residual share in the response header and the related notes. False hides all of it; non-residual figures are unaffected.",
      "default": true
    },
    "lang": {
      "type": "string",
      "enum": [
        "bg",
        "cs",
        "da",
        "de",
        "el",
        "en",
        "es",
        "et",
        "fi",
        "fr",
        "ga",
        "hr",
        "hu",
        "it",
        "lt",
        "lv",
        "mt",
        "nl",
        "pl",
        "pt",
        "ro",
        "sk",
        "sl",
        "sv"
      ],
      "title": "Lang",
      "description": "Language for translated labels in the response: one of the listed ones (the languages the metadata exists in); any other is refused.",
      "default": "en"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "$defs": {
    "Basket": {
      "properties": {
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Label",
          "description": "The basket's display label; default: the pieces' codes joined with '+'."
        },
        "pieces": {
          "items": {
            "$ref": "#/$defs/Piece"
          },
          "type": "array",
          "maxItems": 50,
          "minItems": 1,
          "title": "Pieces",
          "description": "The pieces summed into this basket."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "pieces"
      ],
      "title": "Basket",
      "description": "A nonempty tuple of pieces summed into one displayed line."
    },
    "Frequency": {
      "type": "string",
      "enum": [
        "month",
        "quarter",
        "year"
      ],
      "title": "Frequency",
      "description": "The resampling frequency of a series."
    },
    "Piece": {
      "properties": {
        "customs_code": {
          "type": "string",
          "title": "Customs Code",
          "description": "The customs code: 2/4/6/8 digits, 'TOTAL', or a residual spelling (850440XX, 85SSS999, 85SSS)."
        },
        "from_month": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "\\d{4}-\\d{2}",
              "description": "A calendar month, 'YYYY-MM'."
            },
            {
              "type": "null"
            }
          ],
          "title": "From Month",
          "description": "Inclusive first month of the window, ISO 'YYYY-MM'; null = the request's period_start."
        },
        "to_month": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "\\d{4}-\\d{2}",
              "description": "A calendar month, 'YYYY-MM'."
            },
            {
              "type": "null"
            }
          ],
          "title": "To Month",
          "description": "Inclusive last month of the window, ISO 'YYYY-MM'; null = the request's period_end."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "customs_code"
      ],
      "title": "Piece",
      "description": "Every declaration under one code in one optional month window."
    }
  }
}