{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/genhttp-dev/json-schema/genhttp-dev-analytics-response-schema.json",
  "title": "AnalyticsResponse",
  "description": "What was counted of a lambda's visitors, as its owner is shown it.\n\nWhile counting is switched off, everything from `totals` to `crawlers` is absent.",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/genhttp-dev-v1-openapi.json#/components/schemas/AnalyticsResponse",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "enabled": {
      "type": "boolean",
      "description": "Whether its visits are counted"
    },
    "since": {
      "type": [
        "string",
        "null"
      ],
      "description": "When counting was switched on",
      "format": "date-time"
    },
    "tier": {
      "type": "string",
      "description": "`Free`, `Premium` or `Demo` - which decides how many days are shown"
    },
    "days": {
      "type": "integer",
      "description": "How many days this answer covers, today included",
      "format": "int32"
    },
    "window": {
      "type": "integer",
      "description": "The most days its tier shows",
      "format": "int32"
    },
    "kept": {
      "type": "integer",
      "description": "How many days are kept of every lambda, whatever its tier shows",
      "format": "int32"
    },
    "from": {
      "type": "string",
      "description": "The first day of the answer, in UTC",
      "format": "date"
    },
    "to": {
      "type": "string",
      "description": "The last day of the answer: today, in UTC",
      "format": "date"
    },
    "earliest": {
      "type": [
        "string",
        "null"
      ],
      "description": "The first day anything was counted on - before `from` where more is kept than shown",
      "format": "date"
    },
    "totals": {
      "description": "The days of the answer, summed",
      "nullable": true,
      "$ref": "#/$defs/AnalyticsTotalsResponse"
    },
    "previous": {
      "description": "The same number of days before, summed - only where the tier shows those as well",
      "nullable": true,
      "$ref": "#/$defs/AnalyticsTotalsResponse"
    },
    "daily": {
      "type": [
        "array",
        "null"
      ],
      "description": "Each day of the answer, oldest first, days without visits included",
      "items": {
        "$ref": "#/$defs/AnalyticsDayResponse"
      }
    },
    "pages": {
      "type": [
        "array",
        "null"
      ],
      "description": "The paths that were answered, the most viewed first",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "referrers": {
      "type": [
        "array",
        "null"
      ],
      "description": "The sites people came from, by host",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "countries": {
      "type": [
        "array",
        "null"
      ],
      "description": "The countries their addresses are registered in, by ISO code; empty where not known",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "devices": {
      "type": [
        "array",
        "null"
      ],
      "description": "`desktop`, `mobile`, `tablet`, `bot` or `other`",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "browsers": {
      "type": [
        "array",
        "null"
      ],
      "description": "The browsers of people - programs are not counted here",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "systems": {
      "type": [
        "array",
        "null"
      ],
      "description": "The operating systems of people",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "crawlers": {
      "type": [
        "array",
        "null"
      ],
      "description": "Whose programs came: search engines, AIs, chats showing a preview. The names in `confirmedCrawlers` stand for visits confirmed by their addresses, `unconfirmed` for claims to be one of them from elsewhere, and every other value for a kind of crawler.",
      "items": {
        "$ref": "#/$defs/AnalyticsValueResponse"
      }
    },
    "updated": {
      "type": [
        "string",
        "null"
      ],
      "description": "When visits were last written down; the visits since then are not in this answer yet",
      "format": "date-time"
    },
    "intervalSeconds": {
      "type": "integer",
      "description": "How often visits are written down, in seconds",
      "format": "int32"
    },
    "confirmedCrawlers": {
      "type": "array",
      "description": "The operators whose crawlers are confirmed by the addresses they publish - Google, Bing, OpenAI, Apple, Perplexity - as far as those could be fetched",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "AnalyticsDayResponse": {
      "type": "object",
      "description": "What was counted on one day.",
      "additionalProperties": false,
      "properties": {
        "date": {
          "type": "string",
          "description": "The day, in UTC",
          "format": "date"
        },
        "totals": {
          "description": "What was counted on it",
          "$ref": "#/$defs/AnalyticsTotalsResponse"
        }
      }
    },
    "AnalyticsTotalsResponse": {
      "type": "object",
      "description": "What was counted over some days, summed.",
      "additionalProperties": false,
      "properties": {
        "hits": {
          "type": "integer",
          "description": "Every request answered - pages, the files they load, calls of an API",
          "format": "int64"
        },
        "views": {
          "type": "integer",
          "description": "The requests that were somebody opening a page - people and programs alike",
          "format": "int64"
        },
        "botViews": {
          "type": "integer",
          "description": "Of the views, those of programs rather than people: crawlers, and whatever names no browser. The pages people opened are the views less these.",
          "format": "int64"
        },
        "visitors": {
          "type": "integer",
          "description": "Different people who opened a page, each counted once a day - summed over days, one who came back is counted again",
          "format": "int64"
        },
        "failed": {
          "type": "integer",
          "description": "Requests answered with a server error",
          "format": "int64"
        },
        "rejected": {
          "type": "integer",
          "description": "Requests answered with a client error, not found included",
          "format": "int64"
        },
        "bytes": {
          "type": "integer",
          "description": "What the responses carried, where that was known, in bytes",
          "format": "int64"
        },
        "averageMillis": {
          "type": "number",
          "description": "The mean time to answer a request, in milliseconds",
          "format": "double"
        }
      }
    },
    "AnalyticsValueResponse": {
      "type": "object",
      "description": "One value visits are counted by, and how often it came up.",
      "additionalProperties": false,
      "properties": {
        "value": {
          "type": "string",
          "description": "The path, the host, the country code or the name; `(other)` gathers what did not fit into a day's list"
        },
        "hits": {
          "type": "integer",
          "description": "Requests it was part of",
          "format": "int64"
        },
        "views": {
          "type": "integer",
          "description": "Pages opened it was part of",
          "format": "int64"
        },
        "botViews": {
          "type": "integer",
          "description": "Of those, the pages programs opened rather than people",
          "format": "int64"
        }
      }
    }
  }
}