{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://caliperpress.com/api/schema/section_slice.json",
 "title": "Section file (section_slice)",
 "description": "data.json of a section page /<section>/: every record of the section with its latest main check.",
 "type": "object",
 "additionalProperties": false,
 "required": [
  "schema",
  "schema_version",
  "section",
  "generated_at",
  "license",
  "index",
  "objects"
 ],
 "properties": {
  "schema": {
   "const": "section_slice"
  },
  "schema_version": {
   "const": "1"
  },
  "section": {
   "type": "string",
   "description": "Section of the site, as in the address."
  },
  "generated_at": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
   "description": "When the file was built, ISO 8601 in UTC."
  },
  "license": {
   "type": [
    "string",
    "null"
   ],
   "description": "License of our measurements."
  },
  "index": {
   "type": [
    "object",
    "null"
   ],
   "properties": {
    "value": {
     "type": [
      "string",
      "null"
     ],
     "pattern": "^-?[0-9]+(\\.[0-9]+)?$",
     "description": "Decimal string, such as \"2.99\"; null when unknown."
    },
    "unit": {
     "type": "string",
     "pattern": "^(?:ai_credits_per_month|answer|answers_per_day|blocked_agents|boolean|characters_per_month|completions_per_month|count|credits_per_month|date|days|devices|files_per_chat|flow_credits|fraction|gb_per_user|hours|hours_per_month|index_points|million_tokens|minutes|minutes_per_month|ms|not_determined|page_currency_per_month|percent|requests_per_minute|text|thousand_tokens|times_base_plan|tokens|tokens_per_minute|usd_per_1000_characters|usd_per_1m_tokens|usd_per_hour|usd_per_token|video_minutes_per_month|words|words_per_month|(?:usd|eur|chf|gbp)_per_(?:month|year|hour|day|page|credit|minute|token|1m_tokens|1000_characters|[0-9]+_(?:months|pages|credits|characters|minutes|tokens|hours|words)))(?:; (?:ai_credits_per_month|answer|answers_per_day|blocked_agents|boolean|characters_per_month|completions_per_month|count|credits_per_month|date|days|devices|files_per_chat|flow_credits|fraction|gb_per_user|hours|hours_per_month|index_points|million_tokens|minutes|minutes_per_month|ms|not_determined|page_currency_per_month|percent|requests_per_minute|text|thousand_tokens|times_base_plan|tokens|tokens_per_minute|usd_per_1000_characters|usd_per_1m_tokens|usd_per_hour|usd_per_token|video_minutes_per_month|words|words_per_month|(?:usd|eur|chf|gbp)_per_(?:month|year|hour|day|page|credit|minute|token|1m_tokens|1000_characters|[0-9]+_(?:months|pages|credits|characters|minutes|tokens|hours|words))))*$",
     "description": "Unit code, such as usd_per_month."
    },
    "data_status": {
     "type": "string",
     "enum": [
      "measured",
      "stated_by_source",
      "calculated",
      "unknown"
     ],
     "description": "measured, stated_by_source, calculated or unknown."
    },
    "n": {
     "type": "integer",
     "minimum": 0
    },
    "reason": {
     "type": [
      "string",
      "null"
     ],
     "description": "Why the value is unknown or why the entry was not counted."
    },
    "time": {
     "type": [
      "string",
      "null"
     ],
     "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
     "description": "Time of the check, ISO 8601 in UTC."
    },
    "title_en": {
     "type": "string"
    },
    "methodology_en": {
     "type": "string"
    },
    "currency": {
     "type": "string",
     "pattern": "^[A-Z]{3}$",
     "description": "ISO 4217 currency of a money unit."
    },
    "range": {
     "type": "object",
     "additionalProperties": false,
     "required": [
      "min",
      "max"
     ],
     "properties": {
      "min": {
       "type": [
        "string",
        "null"
       ],
       "pattern": "^-?[0-9]+(\\.[0-9]+)?$"
      },
      "max": {
       "type": [
        "string",
        "null"
       ],
       "pattern": "^-?[0-9]+(\\.[0-9]+)?$"
      }
     },
     "description": "Lowest and highest contribution to the index, as decimal strings; null when unknown."
    },
    "participants": {
     "type": "array",
     "items": {
      "type": "string",
      "pattern": "^[a-z0-9-]+:[a-z0-9._-]+$"
     },
     "description": "Records counted in the index."
    }
   },
   "description": "The section's index value with its window and sample size; null when the section has none."
  },
  "objects": {
   "type": "array",
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "object_id",
     "name",
     "url",
     "plan",
     "latest"
    ],
    "properties": {
     "object_id": {
      "type": "string",
      "pattern": "^[a-z0-9-]+:[a-z0-9._-]+$",
      "description": "Record id: <section>:<record>."
     },
     "name": {
      "type": "string"
     },
     "url": {
      "type": "string",
      "pattern": "^https://"
     },
     "plan": {
      "type": [
       "string",
       "null"
      ]
     },
     "latest": {
      "anyOf": [
       {
        "type": "object",
        "additionalProperties": false,
        "required": [],
        "properties": {
         "measurement_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{16}$",
          "description": "Stable id of one check."
         },
         "question": {
          "type": "string",
          "minLength": 8,
          "maxLength": 300,
          "description": "What the check answers, in plain words."
         },
         "measured": {
          "type": "object",
          "additionalProperties": false,
          "required": [
           "value",
           "unit"
          ],
          "properties": {
           "value": {
            "type": [
             "string",
             "null"
            ],
            "pattern": "^-?[0-9]+(\\.[0-9]+)?$",
            "description": "Decimal string, such as \"2.99\"; null when unknown."
           },
           "text": {
            "type": [
             "string",
             "null"
            ],
            "maxLength": 500,
            "description": "The answer in words, when the value is not a number."
           },
           "unit": {
            "type": "string",
            "pattern": "^(?:ai_credits_per_month|answer|answers_per_day|blocked_agents|boolean|characters_per_month|completions_per_month|count|credits_per_month|date|days|devices|files_per_chat|flow_credits|fraction|gb_per_user|hours|hours_per_month|index_points|million_tokens|minutes|minutes_per_month|ms|not_determined|page_currency_per_month|percent|requests_per_minute|text|thousand_tokens|times_base_plan|tokens|tokens_per_minute|usd_per_1000_characters|usd_per_1m_tokens|usd_per_hour|usd_per_token|video_minutes_per_month|words|words_per_month|(?:usd|eur|chf|gbp)_per_(?:month|year|hour|day|page|credit|minute|token|1m_tokens|1000_characters|[0-9]+_(?:months|pages|credits|characters|minutes|tokens|hours|words)))(?:; (?:ai_credits_per_month|answer|answers_per_day|blocked_agents|boolean|characters_per_month|completions_per_month|count|credits_per_month|date|days|devices|files_per_chat|flow_credits|fraction|gb_per_user|hours|hours_per_month|index_points|million_tokens|minutes|minutes_per_month|ms|not_determined|page_currency_per_month|percent|requests_per_minute|text|thousand_tokens|times_base_plan|tokens|tokens_per_minute|usd_per_1000_characters|usd_per_1m_tokens|usd_per_hour|usd_per_token|video_minutes_per_month|words|words_per_month|(?:usd|eur|chf|gbp)_per_(?:month|year|hour|day|page|credit|minute|token|1m_tokens|1000_characters|[0-9]+_(?:months|pages|credits|characters|minutes|tokens|hours|words))))*$",
            "description": "Unit code, such as usd_per_month."
           },
           "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "ISO 4217 currency of a money unit."
           },
           "range": {
            "type": [
             "object",
             "null"
            ],
            "additionalProperties": false,
            "required": [
             "min",
             "max"
            ],
            "properties": {
             "min": {
              "type": [
               "string",
               "null"
              ],
              "pattern": "^-?[0-9]+(\\.[0-9]+)?$"
             },
             "max": {
              "type": [
               "string",
               "null"
              ],
              "pattern": "^-?[0-9]+(\\.[0-9]+)?$"
             }
            },
            "description": "Lowest and highest contribution to the index, as decimal strings; null when unknown."
           }
          },
          "description": "The value this check recorded."
         },
         "data_status": {
          "type": "string",
          "enum": [
           "measured",
           "stated_by_source",
           "calculated",
           "unknown"
          ],
          "description": "measured, stated_by_source, calculated or unknown."
         },
         "time": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "description": "Time of the check, ISO 8601 in UTC."
         },
         "region": {
          "type": "string",
          "pattern": "^[A-Z]{2}$",
          "description": "Two-letter code of the country the value was shown in."
         },
         "region_name": {
          "type": "string",
          "minLength": 1,
          "description": "Name of that country."
         },
         "method_version": {
          "type": "string",
          "minLength": 1,
          "description": "Edition of the method used for this check."
         },
         "source": {
          "type": [
           "string",
           "null"
          ]
         }
        }
       },
       {
        "type": "null"
       }
      ],
      "description": "The last confirmed check of the main question; newer checks that recorded no value are in held_value."
     }
    }
   },
   "description": "Every record of the section with its latest main check."
  }
 }
}