{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cryptokeyhole/json-schema/cryptokeyhole-series-schema.json",
  "title": "Series",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/cryptokeyhole-openapi.json#/components/schemas/Series",
  "type": "object",
  "properties": {
    "metric": {
      "$ref": "#/$defs/Metric"
    },
    "interval": {
      "type": "string"
    },
    "state": {
      "type": "string",
      "description": "current; delayed (the source is late, with its delay); held (not published); locked (above the plan, see locked)."
    },
    "reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "points": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Point"
      }
    },
    "components": {
      "type": "array",
      "description": "The lines of a chart with several, each with its points.",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "points": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/Point"
            }
          }
        }
      }
    },
    "historyStart": {
      "type": [
        "integer",
        "null"
      ]
    },
    "historyEnd": {
      "type": [
        "integer",
        "null"
      ]
    },
    "generatedAt": {
      "type": "integer"
    },
    "sourceObservedAt": {
      "type": [
        "integer",
        "null"
      ]
    },
    "locked": {
      "$ref": "#/$defs/Locked"
    }
  },
  "$defs": {
    "Locked": {
      "type": "object",
      "description": "What a higher plan would include.",
      "properties": {
        "feature": {
          "type": "string"
        },
        "requiredPlan": {
          "type": "string",
          "enum": [
            "plus",
            "pro",
            "team"
          ]
        },
        "requiredPlanName": {
          "type": "string"
        },
        "currentPlan": {
          "type": "string"
        },
        "currentPlanName": {
          "type": "string"
        },
        "upgradePath": {
          "type": "string"
        },
        "allowedIntervals": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "Metric": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "family": {
          "type": "string"
        },
        "unit": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "method": {
          "type": "string"
        },
        "intervals": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "status": {
          "type": "string",
          "description": "held: planned but not published (see reason)."
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        },
        "historyStart": {
          "type": [
            "integer",
            "null"
          ],
          "description": "UTC seconds, the first period."
        },
        "historyEnd": {
          "type": [
            "integer",
            "null"
          ],
          "description": "UTC seconds, the end of the last period (not included)."
        }
      }
    },
    "Point": {
      "type": "object",
      "required": [
        "t",
        "v",
        "finality"
      ],
      "properties": {
        "t": {
          "type": "integer",
          "description": "The period's start, UTC seconds."
        },
        "v": {
          "type": [
            "string",
            "null"
          ],
          "description": "Exact decimal; null where there is no observation."
        },
        "finality": {
          "type": "string",
          "enum": [
            "final",
            "provisional",
            "partial"
          ]
        }
      }
    }
  }
}