{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/commodities-sh/json-schema/commodities-sh-observation-schema.json",
  "title": "Observation",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/commodities-sh-openapi.yml#/components/schemas/Observation",
  "type": "object",
  "required": [
    "instrument",
    "value",
    "unit",
    "as_of",
    "freshness_class",
    "source",
    "license_tag",
    "derived"
  ],
  "properties": {
    "instrument": {
      "type": "string"
    },
    "value": {
      "type": "number"
    },
    "unit": {
      "type": "string"
    },
    "as_of": {
      "type": "string",
      "format": "date"
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "freshness_class": {
      "type": "string",
      "enum": [
        "eod",
        "weekly",
        "monthly",
        "decree",
        "intraday",
        "delayed"
      ]
    },
    "quality": {
      "type": "string",
      "enum": [
        "official",
        "indicative",
        "derived",
        "delayed"
      ]
    },
    "derived": {
      "type": "boolean"
    },
    "source": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "series_id": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      }
    },
    "license_tag": {
      "type": "string"
    },
    "provenance": {
      "type": "object",
      "properties": {
        "retrieved_at": {
          "type": "string",
          "format": "date-time"
        },
        "cache_hit": {
          "type": "boolean"
        },
        "cache_ttl_s": {
          "type": "number"
        }
      }
    },
    "prior": {
      "type": "number",
      "description": "Previous print value when history exists"
    },
    "pct_change": {
      "type": "number",
      "description": "Percent change vs prior print"
    },
    "short_history": {
      "type": "array",
      "description": "Newest-first short history (≤8 points)",
      "items": {
        "type": "object",
        "properties": {
          "as_of": {
            "type": "string",
            "format": "date"
          },
          "value": {
            "type": "number"
          }
        }
      }
    },
    "cite": {
      "type": "string",
      "description": "One-line citation for agents"
    }
  }
}