{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://meka.im/data/google-trends-anchors/baselines/v1/schema.json",
  "title": "MEKA Google Trends Baseline Anchors v1",
  "description": "Google Ads Keyword Planner daily-search anchors used to calibrate Google Trends web relative interest by region.",
  "type": "object",
  "required": [
    "$schema",
    "schemaVersion",
    "version",
    "searchProperty",
    "category",
    "tierBoundaries",
    "regions"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://meka.im/data/google-trends-anchors/baselines/v1/schema.json",
      "description": "The JSON Schema document for this data format."
    },
    "schemaVersion": {
      "type": "integer",
      "const": 1,
      "description": "Version of the baseline anchor format."
    },
    "version": {
      "type": "string",
      "format": "date",
      "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
      "description": "Publication date of this baseline index."
    },
    "searchProperty": {
      "type": "string",
      "const": "web",
      "description": "Google Trends search property for the anchor query. web corresponds to Google Search."
    },
    "category": {
      "type": "integer",
      "const": 0,
      "description": "Google Trends category identifier. Zero means all Google Trends categories; this is not a Google Ads category."
    },
    "tierBoundaries": {
      "type": "array",
      "description": "Strictly increasing integer daily-search boundaries, starting at 100. A tier starts at its lower boundary and ends before the next boundary; the final tier has no upper bound.",
      "minItems": 1,
      "uniqueItems": true,
      "$comment": "JSON Schema 2020-12 cannot compare adjacent numeric items, so the producer must also enforce strict increase.",
      "prefixItems": [
        {
          "type": "integer",
          "const": 100
        }
      ],
      "items": {
        "type": "integer",
        "minimum": 100
      }
    },
    "regions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/region"
      }
    }
  },
  "$defs": {
    "quality": {
      "type": "object",
      "description": "Observed Google Trends quality for one validation sample. This does not represent a version or independent estimate of absolute search volume.",
      "required": [
        "startUtc",
        "endUtc",
        "intervalSeconds",
        "pointCount",
        "nonzeroPoints",
        "peak"
      ],
      "additionalProperties": false,
      "properties": {
        "startUtc": {
          "type": "string",
          "format": "date-time",
          "description": "UTC timestamp of the first observed point."
        },
        "endUtc": {
          "type": "string",
          "format": "date-time",
          "description": "UTC timestamp of the last observed point."
        },
        "intervalSeconds": {
          "type": "integer",
          "minimum": 1,
          "description": "Nominal spacing between observations in seconds."
        },
        "pointCount": {
          "type": "integer",
          "minimum": 1,
          "description": "Number of observed points in the validation window."
        },
        "nonzeroPoints": {
          "type": "integer",
          "minimum": 0,
          "description": "Number of observed points with nonzero relative interest."
        },
        "peak": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "Peak relative interest on this source sample batch's own Google Trends 0-100 scale. Values are scoped to that batch and are not comparable across separate requests."
        }
      }
    },
    "anchor": {
      "type": "object",
      "required": [
        "term",
        "language",
        "tierMinDailySearches",
        "dailySearches",
        "validation"
      ],
      "additionalProperties": false,
      "properties": {
        "term": {
          "type": "string",
          "minLength": 1,
          "description": "Stable search term used as the volume anchor."
        },
        "language": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "description": "Google Ads data language used for the anchor term, or null when unknown."
        },
        "tierMinDailySearches": {
          "type": "integer",
          "description": "Inclusive lower boundary of the anchor's daily-search tier. Producers must use one of tierBoundaries."
        },
        "dailySearches": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Tier-rounded median of Google Ads monthly searches divided by the number of days in each month across 12 consecutive complete months."
        },
        "validation": {
          "type": "object",
          "description": "Google Trends validation samples for the anchor term. The 7d and 90d entries are separate validation windows, not alternative versions of an absolute search-volume estimate.",
          "required": [
            "7d",
            "90d"
          ],
          "additionalProperties": false,
          "properties": {
            "7d": {
              "$ref": "#/$defs/quality",
              "description": "Seven-day Google Trends validation sample."
            },
            "90d": {
              "$ref": "#/$defs/quality",
              "description": "Ninety-day Google Trends validation sample."
            }
          }
        }
      }
    },
    "source": {
      "type": "object",
      "required": [
        "provider",
        "url",
        "fromMonth",
        "toMonth",
        "searchPartners"
      ],
      "additionalProperties": false,
      "properties": {
        "provider": {
          "type": "string",
          "const": "Google Ads Keyword Planner"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Actor source webpage for these baseline measurements."
        },
        "fromMonth": {
          "type": "string",
          "pattern": "^\\d{4}-(0[1-9]|1[0-2])$",
          "description": "First of 12 consecutive complete months included in dailySearches, in inclusive YYYY-MM form."
        },
        "toMonth": {
          "type": "string",
          "pattern": "^\\d{4}-(0[1-9]|1[0-2])$",
          "description": "Last of 12 consecutive complete months included in dailySearches, in inclusive YYYY-MM form."
        },
        "searchPartners": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether Google Ads search-partner volume is included. False is expected for country sources; Worldwide may be null when the source did not disclose the setting."
        }
      }
    },
    "region": {
      "type": "object",
      "required": [
        "geo",
        "source",
        "anchors"
      ],
      "additionalProperties": false,
      "properties": {
        "geo": {
          "description": "Two-letter uppercase country code, or an empty string for Worldwide.",
          "oneOf": [
            {
              "type": "string",
              "const": ""
            },
            {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            }
          ]
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "anchors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/anchor"
          }
        }
      }
    }
  }
}
